[英]textView.SetText working only when text is long
For some odd reason the setText only works when the text is above 600+ chars... I get the text from my database. 出于某种奇怪的原因,setText仅在文本超过600个字符时才起作用。我从数据库中获取了文本。
Here is the code 这是代码
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 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... 当文字包含许多字符时,它可以工作...
You need to remove the
View
from yourLayout
which is between bothText Views
because it is overlapping your Body Text. 您需要从两个Text Views
之间的Layout
删除View
,因为它与您的正文文本重叠。Also if you set
android:layout_height="1dp"
in yourView
here then it will work. 另外,如果您在此处的View
设置了android:layout_height="1dp"
,那么它将起作用。
Refer this only. 仅参考此。
<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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.