【发布时间】:2016-05-20 09:51:53
【问题描述】:
由于某些奇怪的原因,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...
【问题讨论】:
-
也尝试使用 ScrollView
-
文本较少时发布屏幕截图
-
mTour.getOverview()是字符串值吗? -
@jaydroider 我添加它只是为了美观。 :P
-
感谢大家抽出宝贵时间帮助我!
标签: java android android-studio textview settext