gpt4 book ai didi

android - android 2.3 上的 Navigation Drawer ListView 选择问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:16:01 24 4
gpt4 key购买 nike

我尝试为旧版 android 2.3 自定义抽屉导航菜单
为此,我使用 developer.android.com 的官方 SampleNavigationDrawer
this tutorial for implements ActionBarCompat .

android.support.v4.widget.DrawerLayout 中使用下一个 ListView:

<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:fadingEdge="none"
android:focusable="false"
android:saveEnabled="true" />

使用 drawer_list_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_selector"
android:drawableLeft="@drawable/selector"
android:drawablePadding="16dp"
android:gravity="center_vertical"
android:minHeight="48dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="@drawable/text_color_selector" />

bg_选择器.xml :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/yellow" />
<item android:state_pressed="true" android:drawable="@color/red" />
<item android:state_checked="true" android:drawable="@color/lemon" />
<item android:state_activated="true" android:drawable="@color/orange" />
<item android:state_selected="true" android:drawable="@color/green_pastel" />
<item android:state_active="true" android:drawable="@color/gold" />
<item android:state_accelerated="true" android:drawable="@color/blue" />
<item android:state_enabled="true" android:drawable="@color/pink_dark" />
<item android:drawable="@color/black" />
</selector>

选择器.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/action_search" />
<item android:state_activated="true" android:drawable="@drawable/ic_launcher" />
<item android:drawable="@drawable/ic_drawer" />
</selector>

文本颜色选择器.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">  
<item android:state_pressed="true" android:color="@color/blue" />
<item android:state_activated="true" android:color="@color/green_pastel_dark" />
<item android:color="@color/white" />
</selector>

问题:

For API14+ it looks awesome but on android 2.3.6 selector isn't shown. (see this screenshots)

附言直到 API 级别 11 才引入 state_activated 参数

最佳答案

关于android - android 2.3 上的 Navigation Drawer ListView 选择问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19428303/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com