java无法在代码中使用tabBackground动态设置选项卡背景
嗨,朋友们,请帮助我,我想让布局像前两个屏幕,但我得到的布局像3,4个屏幕,我用选择器。在这里的xml中,我使用了tabBackground,称为selector drawable,如果我可以在java代码中获得tabBackground,那么我可以使用位置来设置它,但是我找不到,请帮我
这是我的布局代码
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:orientation="vertical"
>
<安卓.support.design.widget.TabLayout
安卓:id="@+id/icon_tabs"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:background="@drawable/toolbar_bg"
安卓:layout_marginRight="10dp"
安卓:layout_marginLeft="10dp"
安卓:layout_marginTop="10dp"
app:tabBackground="@drawable/tab_background"
app:tabIndicatorColor="@color/transparent"
app:tabGravity="fill"
app:tabMode="fixed" />
<FrameLayout
安卓:id="@+id/main_fragment"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent" />
</LinearLayout>
我的选择器代码
<selector xmlns:安卓="http://schemas.安卓.com/apk/res/安卓">
<item 安卓:drawable="@drawable/tab_bg_redcolor" 安卓:state_selected="true"/>
<item 安卓:drawable="@drawable/toolbar_bg"/>
</selector>
共 (0) 个答案