簡體   English   中英

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>

當文字包含許多字符時,它可以工作...

在此處輸入圖片說明

低於500-600時不會...

在此處輸入圖片說明

您需要從兩個Text Views之間的Layout刪除View ,因為它與您的正文文本重疊。

另外,如果您在此處的View設置了android:layout_height="1dp" ,那么它將起作用。

僅參考此。

<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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM