2017-02-09 13 views
1

タブレイアウトの場合、カスタムレイアウトを拡張していますcustom_tab.xml、名前の長さを長くするとバッジビューが途切れてしまいます。カスタムtabLayoutバッジビューが途切れる[Android]

私はすべてのビュー、まだ効果なし

ためwrap_contentを試してみましたが、これはあるcustom_tab.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="wrap_content" 
       android:layout_height="48dp" 
       android:layout_margin="5dp" 
       android:orientation="horizontal"> 

    <TextView 

     android:id="@+id/tv_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:text="title" 
     android:textColor="@color/white" 
     android:textSize="20sp" 
     android:textStyle="bold" /> 

    <TextView 

     android:id="@+id/tv_count" 
     android:layout_width="31dp" 
     android:layout_height="31dp" 
     android:layout_gravity="center" 
     android:layout_margin="5dp" 
     android:background="@drawable/badge_drawable" 
     android:gravity="center" 
     android:textColor="#000000" 
     android:textSize="12sp" /> 

</LinearLayout> 

これはtablayout

private void setupTabIcons() { 
    for (int i = 0; i < NewFragment.categories.size(); i++) { 
     try { 
      LinearLayout currentTabLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); 

      .............................. 
      .............................. 

      tabLayout.getTabAt(i).setCustomView(currentTabLayout); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 
のためのビューを膨張させるためのJavaコードであります

1行で長さを増やしたテキストのスクリーンショットテキストのための偽

スクリーンショットは、両方のケースで、私はへのテキストビューを望むレイアウト からバッジビューをカットenter image description here

真として設定された単一のラインで長さが増加しました一行にする。

誰でもこの問題を解決できますか?

何か助けや提案をいただければ幸いです。

おかげ

+1

こんにちは、Sanoopを修正しますあなたのテキストは長いので –

+0

@DileepPatel返信いただきありがとうございます。私は試しましたが、バッジビューにはほとんど影響を与えませんでした。ビューからはまだ隠されています – Sanoop

+0

テキストが長すぎると、タブのレイアウトは、モードが '固定'に設定されている場合、3つのタブにフィットしようとします。私はtのテキストを縮小しなければなりません彼は同じ要求 –

答えて

0

あなたは1にセットするための「マーキー」プロパティを使用しようとすることができdimens.xmlファイルの下でより高いレベルに幅を設定することにより、問題のタグの下

<dimen name="tab_max_width">XXXdp</dimen> 
関連する問題