我正在尝试使用选择器创建一个按钮,我的按钮可以具有以下状态:
根据上述状态.我需要操纵按钮:
该按钮从我被禁用开始,因此它应该具有禁用的textColor和禁用的按钮背景.但我可以看到默认的textColor(在样式中指定)和没有背景图像!
这是我的选择器button_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"
android:state_enabled="false"
android:textColor="#9D9FA2"
android:drawable="@drawable/button" />
<item android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/button_pressed"/>
<item android:state_pressed="true"
android:state_enabled="false"
android:textColor="#9D9FA2"
android:drawable="@drawable/button"/>
<item android:state_pressed="false"
android:state_enabled="true"
android:drawable="@drawable/button"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
这是我的layout.xml中的按钮声明
<Button android:id="@+id/reserve_button"
android:text="@string/reserve_button"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:paddingRight="15dp"
android:layout_gravity="left"
style="@style/buttonStyle"
android:background="@drawable/button_selector" />
Run Code Online (Sandbox Code Playgroud)
最后这是我的风格(我的默认textColor设置)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="buttonStyle">
<item name="android:textStyle">bold</item>
<item name="android:textColor">#282780</item>
<item name="android:textSize">18sp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
请帮忙!
我正在开始一个新的应用程序,我使用ActionBarSherlock和HoloEverywhereLib.我的min和目标SDK是相同的(10/2.3.3).这只是我可以使用他们拥有的Android运行时快速将其移植到亚马逊Kindle和BB10(已经使用此设置为另一个应用程序,它没有问题).应用程序应该尽可能接近ICS/JB.
对于我的EditTexts,我给他们一个Girgerbread/iOS(圆角,但没有阴影)看他们
几个星期前有人向我提到要抓住Gingerbread的drawable并将它们用于我的EditTexts.但我开始使用我在S/O找到的另一个答案,非常简单:
<EditText
background:"@drawable/edittext_round_white"
..../>
Run Code Online (Sandbox Code Playgroud)
&我的edittext_round_white.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners android:radius="8dp"/>
<stroke android:width="1dp"
android:color="#444"/>
<solid android:color="#FFFFFF" />
</shape>
Run Code Online (Sandbox Code Playgroud)
现在,当我运行应用程序时,有两件事情是不对的
a)根本没有"焦点"(我知道我需要实现这一点,这是问题的关键)
b)光标在我的edittext中根本没有出现(灰色垂直线暗示输入所指向的edittext中的位置)
对于a)我假设我要使用某种选择器或列表,对吧?怎么样?我是Android的样式新手,任何帮助将不胜感激.我唯一要改变的是笔触颜色.
对于b)如何让光标显示?
这里的任何提示/链接/等都非常受欢迎!