textView.SetText 仅在文本较长时有效
textView.SetText working only when text is long
出于某种奇怪的原因,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...
When it's below 500 - 600 it doesn't...
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" />
出于某种奇怪的原因,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...
When it's below 500 - 600 it doesn't...
You need to remove the
View
from yourLayout
which is between bothText Views
because it is overlapping your Body Text.Also if you set
android:layout_height="1dp"
in yourView
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" />