25

これが私のレイアウトViewPagerです。テキストの下にある現在のタブ蛍光ペンの色を変更したいと思います。実は黒色で表示されています。でも、デフォルトでカラーかどうかはわかりません。また、もう1つ疑問があります。このタブを使用するとPagerTitleStrip、蛍光ペンが表示されません。タイトルストリップでそれをもたらす方法はありますか?

これが私のレイアウトです:

  <android.support.v4.view.PagerTabStrip android:id="@+id/pager_title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="@color/pager_titlestrip_bg"    
    android:textColor="@color/pager_titlestrip_text"
    android:paddingTop="5dp"
    android:paddingBottom="4dp" >   
  </android.support.v4.view.PagerTabStrip>
4

3 に答える 3

63

これはうまくいきます。

PagerTabStrip pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_title_strip);
pagerTabStrip.setDrawFullUnderline(true);
pagerTabStrip.setTabIndicatorColor(Color.RED);

ありがとう!

于 2012-09-14T19:21:56.673 に答える
13

これは、jAVAまたはXMLの両方を使用してプログラムで実行できます。

XMLによる

<android.support.design.widget.TabLayout
        android:id="@+id/tabanim_tabs"
        android:layout_width="match_parent"
        app:tabIndicatorHeight="4dp"
        app:tabIndicatorColor="@android:color/white"
        android:layout_height="wrap_content" />

または、もっと簡単に、このコードを解決することもできます

tabLayout.setSelectedTabIndicatorColor(Color.parseColor("#FFFFFF"));

同様に高さを変更するには

tabLayout.setSelectedTabIndicatorHeight((int) (2 * getResources().getDisplayMetrics().density));
于 2015-10-10T16:55:56.713 に答える
1

これは私のプロジェクトで機能します。

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FFF"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/text3"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@color/text3"
    app:tabTextColor="#000" />
于 2017-03-15T06:41:21.230 に答える