由于某些奇怪的原因,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...
答案 0 :(得分:2)
您需要从
View
之间移除Layout
Text Views
,因为它与您的正文文本重叠。此外,如果您在此
android:layout_height="1dp"
设置了View
,那么它就能正常运作。
仅供参考。
<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" />