1

tabStrip の色を白に変更しようとしていますが、以下のコードは機能しませんか? 私は何を間違っていますか?

getTabHost().getTabWidget().setLeftStripDrawable(Color.WHITE);
getTabHost().getTabWidget().setRightStripDrawable(Color.WHITE);
getTabHost().getTabWidget().setStripEnabled(true);
4

3 に答える 3

3

色の代わりにドローアブルを使用する

setLeftStripDrawable は描画可能なリソースを必要としていますが、引数として int を指定していることを意味します。

したがって、ここで描画可能な画像を使用してください。または、色を含むドローアブルの xml を使用します。

于 2012-10-09T12:20:44.703 に答える
0

タブ ストリップの背景の色を変更したいと考えています。ルート要素を次のように持つレイアウトを作成することで、これを実現できます。

tab_strip.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FFFFFF">

</android.support.design.widget.TabLayout>

タブを使用しているxmlで、次のようにtab_strip.xmlを追加できます

<include android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        layout="@layout/tab_strip"/>

これにより、タブ ストリップの色が白になります。

于 2015-10-17T05:26:24.960 に答える