gpt4 book ai didi

android-button 背景可绘制对象不起作用

转载 作者:行者123 更新时间:2023-11-29 00:18:40 25 4
gpt4 key购买 nike

这是我的 xml drawbale 代码,名称为 btntheme.xml :

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_enabled="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light" android:state_enabled="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_pressed="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_focused_holo_light" android:state_enabled="true" android:state_focused="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_enabled="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_focused_holo_light" android:state_focused="true"/>
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light"/>

</selector>

我已将所有具有这些名称的图像放在 drawable-hdpi 文件夹中。

这是我的布局和按钮:

<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:background="@drawable/btntheme"
android:textSize="@dimen/font_size_smallerButton" />

它不工作,它根本不改变按钮主题?

你能帮我解决一下吗?

谢谢

最佳答案

尝试添加 <?xml version="1.0" encoding="utf-8"?>在 xml 文件和 xml 文件中会喜欢

<?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/custom_tab_indicator_unselected" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/custom_tab_indicator_selected" />

<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/custom_tab_indicator_unselected_focused" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/custom_tab_indicator_selected_focused" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/custom_tab_indicator_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/custom_tab_indicator_selected_pressed" />

<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/custom_tab_indicator_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/custom_tab_indicator_selected_pressed" />
</selector>

在使用它之后,如果它不起作用,那么如果可能的话,尝试使用 ImageView 而不是按钮,我认为这会起作用。谢谢;-)

关于android-button 背景可绘制对象不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24624038/

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