假設我想基於以下條件 1.選擇的Un中的選項卡標籤tablayout設置顏色=藍色 2.當前選項卡=綠色 3.選擇選項卡=紅色如何更改tablayout中選定選項卡的顏色?
這裏我使用下面的代碼改變顏色選擇,而當前標籤
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- UNSELECTED TAB STATE -->
<item android:state_selected="false" android:state_pressed="false">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Bottom indicator color for the UNSELECTED tab state -->
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#65acee" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
<!-- Current TAB STATE -->
<item android:state_selected="true" android:state_pressed="false">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Tab background color for the SELECTED tab state -->
<item>
<shape>
<solid android:color="#cef9ff"/>
</shape>
</item>
<!-- Bottom indicator color for the SELECTED tab state -->
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#5beea6" android:width="2dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
,但未能保留先前選定的標籤
汽車讀數選擇狀態 拍攝照片和簽名是未選中狀態
正在使用視圖尋呼機......從車上閱讀移動拍攝的照片後,...汽車閱讀背景應該是綠色
2.當前標籤=綠色3.所選標籤=紅色的差異? –
假設是在標籤位置2然後標籤2是當前標籤 –
如果您在標籤位置2,那麼它必須選擇標籤右側? –