如何在选项卡上方添加行 android tablayout
how to add line above tabs android tablayout
需要帮助
我搜索了我的要求,但没有找到所以发布我自己的问题。
我需要在选项卡上方而不是下方显示行,因为所有解决方案都是在选项卡文本下方添加行。
我应该使用自定义选项卡还是android支持这种情况而不进行自定义??
我看过的链接如下
没有发布代码,因为我想知道应该使用什么。你的建议会很有帮助。谢谢
尝试在 res/drawable
文件夹中创建背景并设置 app:tabBackground="@drawable/selector"
制作你喜欢的 Tablayout
<android.support.design.widget.TabLayout
android:id="@+id/detail_tabs"
android:layout_width="match_parent"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabIndicatorHeight="0dp"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabBackground="@drawable/selector" />
这里selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:state_pressed="false">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="3dp" android:left="-5dp" android:right="-5dp" android:bottom="-5dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorWhite"/>
<stroke android:color="@color/colorPrimary" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true" android:state_pressed="true">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="3dp" android:left="-5dp" android:right="-5dp" android:bottom="-5dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorWhite"/>
<stroke android:color="@color/colorPrimary" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
希望它能起作用,如果没有,请添加评论。
需要帮助
我搜索了我的要求,但没有找到所以发布我自己的问题。
我需要在选项卡上方而不是下方显示行,因为所有解决方案都是在选项卡文本下方添加行。
我应该使用自定义选项卡还是android支持这种情况而不进行自定义??
我看过的链接如下
没有发布代码,因为我想知道应该使用什么。你的建议会很有帮助。谢谢
尝试在 res/drawable
文件夹中创建背景并设置 app:tabBackground="@drawable/selector"
制作你喜欢的 Tablayout
<android.support.design.widget.TabLayout
android:id="@+id/detail_tabs"
android:layout_width="match_parent"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabIndicatorHeight="0dp"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabBackground="@drawable/selector" />
这里selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:state_pressed="false">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="3dp" android:left="-5dp" android:right="-5dp" android:bottom="-5dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorWhite"/>
<stroke android:color="@color/colorPrimary" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true" android:state_pressed="true">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="3dp" android:left="-5dp" android:right="-5dp" android:bottom="-5dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorWhite"/>
<stroke android:color="@color/colorPrimary" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
希望它能起作用,如果没有,请添加评论。