使用此代码实现了Round Corner效果后,我已经失去了EditText的橙色突出显示效果。有人能告诉我如何恢复精彩集锦效果吗?
谢谢
round_corner_button_bg.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="45"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<solid
android:color="#FFF" />
</shape>
EditText.xml
<EditText
android:id="@+id/loginPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_corner_button_bg"
android:password="true" />
答案 0 :(得分:1)
如果您点击onClick橙色效果尝试使用''属性环绕代码并为onClicked和normal设置颜色:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="45"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<solid
android:color="#ffdd00" />
</shape>
</item>
<item>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="45"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<solid
android:color="#FFF" />
</shape>
</item>
</selector>
答案 1 :(得分:0)
你必须使用选择标签 你可以了解它here
修改强>
选择视图时,请提供所需的颜色。
编辑 请根据您的使用情况进行自定义
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize=["true" | "false"]
android:dither=["true" | "false"]
android:variablePadding=["true" | "false"] >
<item
android:drawable="@[package:]drawable/drawable_resource"//YOUR ROUNDED CORNER XML
android:state_pressed=["true" | "false"]
android:state_focused=["true" | "false"]
android:state_hovered=["true" | "false"]
android:state_selected=["true" | "false"]
android:state_checkable=["true" | "false"]
android:state_checked=["true" | "false"]
android:state_enabled=["true" | "false"]
android:state_activated=["true" | "false"]
android:state_window_focused=["true" | "false"] />
</selector>