问题描述
我试图让我的tabicon当标签是pssed $ P $改变(即当它时,你PSS的标签$ P $,但还没有公布尚未改变颜色)。我如下创建的选择:
I'm trying to get my tabicon to change when a tab is pressed (i.e. when it changes color when you press the tab, but haven't released yet). I've created a selector as follows:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/ic_tab_icon1" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/ic_tab_icon2" />
<!-- Focused states -->
<item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/ic_tab_icon3" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/ic_tab_icon4" />
<!-- Pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/ic_tab_icon5" />
</selector>
然而,由于某种原因,只有前两个状态到达(仅ICON1和图标2时)。谁能告诉我正确的状态是个什么pssed $ P $,但没有选择选项卡?
However, for some reason only the first two states are reached (only icon1 and icon 2 are used). Can anyone tell me what the correct state is for a "pressed but not selected" tab?
*编辑阐明新形势
推荐答案
这是默认的 tab_indicator.xml
为Android。从这个<一个有href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/drawable/tab_indicator.xml;h=65df805d73ed4e759fe3f856bd5f6731bdb02ab0;hb=refs/heads/donut"相对=nofollow> gitkernal 。你必须维护所有这些国家。
this is the default tab_indicator.xml
for android. got from this gitkernal. you have to maintain all these states.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/ic_tab_north_normal" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/ic_tab_north_selected" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/ic_tab_north_normal" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/ic_tab_north_selected" />
<!-- Pressed -->
<item android:state_pressed="true" android:drawable="@drawable/ic_tab_north_normal" />
</selector>
这篇关于什么是$ P $的状态pssed选项卡中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!