如何通過Java代碼動態更改選項卡背景這裏是我的佈局代碼如果我可以獲得應用程序:tabBackground =「@ drawable/tab_background 「在Java代碼的話,我可以能夠通過選擇得到像第一圖像所需的畫面通過選項卡選擇的位置來改變背景繪製的,但我不能找到它的任何地方,請幫助我的朋友在Java代碼中沒有選項卡背景屬性來動態更改選項卡背景
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.design.widget.TabLayout
android:id="@+id/icon_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/toolbar_bg"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
app:tabBackground="@drawable/tab_background"
app:tabIndicatorColor="@color/transparent"
app:tabGravity="fill"
app:tabMode="fixed" />
<FrameLayout
android:id="@+id/main_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
我需要佈局像下面
但我得到這個佈局
它不工作,因爲我預計 – prominere