【发布时间】:2015-09-16 11:23:13
【问题描述】:
我正在使用 Design TabLayout,
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@color/ColorPrimary"
app:tabIndicatorColor="@color/orange"
app:tabIndicatorHeight="3dp"
/>
我已将自定义视图添加到选项卡
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null">
<ImageView
android:id="@+id/imgTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tab_image"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"/>
<TextView
android:id="@+id/tabTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imgTab"
android:text="Home"
android:background="@null"
android:layout_centerHorizontal="true"
android:textColor="@color/selector_tab_text"/>
</RelativeLayout>
tab.setCustomView(view);
我想在选择选项卡时更改自定义视图中的图像。 尝试在 imageview 上使用 Selector 不起作用。 我无法在运行时将视图分配给 Tab,它只包含 setCustomView 方法。 如何实现?
【问题讨论】:
标签: android android-tabs android-tablelayout