12 android
嗨,谢谢你的阅读.
我有一个问题,我的Android应用程序导航抽屉,我无法改变蓝色的颜色 - 我已经过了所有其他问题从SO,参考Android文档,并尝试了一切到目前为止...但仍然没有运气.我真的希望有人可以提供帮助.
到目前为止的代码:
my_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Blue still showing up! -->
<item android:state_activated="true" android:drawable="@color/lightPink" />
<item android:state_selected="true" android:drawable="@color/lightPink" />
<item android:state_pressed="true" android:drawable="@color/lightPink" />
<item android:state_focused="true" android:drawable="@color/lightPink" />
<item android:drawable="@color/lightPink" />
</selector>
Run Code Online (Sandbox Code Playgroud)
styles.xml
<item name="android:activatedBackgroundIndicator">@drawable/my_background</item>
Run Code Online (Sandbox Code Playgroud)
fragment_navigation_drawer.xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="?android:attr/activatedBackgroundIndicator"
android:listSelector="@drawable/my_background"
tools:context="com.randompractice.app.NavigationDrawerFragment"
/>
Run Code Online (Sandbox Code Playgroud)
我现在已经被困在这24小时了,这让我发疯了.对于我的好奇心告诉我实施的这种愚蠢的小变化,已经变成了一个研究项目.谁能看到我做错了什么?
小智 20
首先,我会尝试删除android:listSelector属性,因为我认为没有必要.
接下来,我会仔细检查您是否已完成以下所有步骤:
的themes.xml
<style name="Theme.mytheme" parent="android:Theme.Holo">
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>
Run Code Online (Sandbox Code Playgroud)
activated_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/my_color" android:state_activated="true" />
<item android:drawable="@android:color/transparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)
colors.xml
<resources>
<item name="my_color" type="color">#ff0000</item>
</resources>
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml中
android:theme="@style/Theme.mytheme"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13301 次 |
| 最近记录: |