gpt4 book ai didi

java - textView.SetText 仅在文本较长时有效

转载 作者:行者123 更新时间:2023-12-02 03:36:58 25 4
gpt4 key购买 nike

由于某些奇怪的原因,setText 仅在文本超过 600 个字符以上时才起作用...我从数据库中获取文本。

这是代码

private void renderViewDescription() {
// reference

final TextView descriptionTextView = (TextView) mRootView.findViewById(R.id.fragment_tour_detail_overview_text);
// content
Log.d("Overview: ",mTour.getOverview()); //Text is always ok
descriptionTextView.setText(mTour.getOverview());
}

XML

    <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/global_spacing_xxs"
android:textAppearance="@style/TextAppearance.CityGuide.Headline"
android:fontFamily="sans-serif-light"
android:text="Overview" />

<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/dividerHorizontal" />


<TextView
android:id="@+id/fragment_tour_detail_overview_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/global_spacing_xxs"
android:text="Body"
android:textAppearance="@style/TextAppearance.CityGuide.Body1"
android:textColor="@color/global_text_secondary"/>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/dividerHorizontal" />


</LinearLayout>
</android.support.v7.widget.CardView>

When text has many chars it works...

enter image description here

When it's below 500 - 600 it doesn't...

enter image description here

最佳答案

You need to remove the View from your Layout which is between both Text Views because it is overlapping your Body Text.

Also if you set android:layout_height="1dp" in your View here then it will work.

仅引用此内容。

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:padding="10dp"
android:singleLine="false"
android:text="Overview"
android:textAppearance="?attr/textAppearanceLargePopupMenu"
android:textColor="#FFF" />

<!--<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/dividerHorizontal" />-->

<TextView
android:id="@+id/fragment_tour_detail_overview_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="OverviewOverviewOverviewOverviewOverviewOverviewOverviewOverviewOverviewOverviewOverviewOverviewO"
android:textAppearance="?attr/textAppearanceLargePopupMenu"
android:textColor="#FFF" />

关于java - textView.SetText 仅在文本较长时有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37343543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com