Hit*_*dra 5 android android-layout
我在textview的右侧有一个箭头图像.我正在使用android:drawableRight="@drawable/arrow"它,它工作正常.但我希望当textview处于选定状态时,我需要显示箭头图像.有什么方法可以通过选择器实现它.
任何人都可以告诉我如何实现它?
导致以下异常.
如果你没有声明默认状态,那么选择器对我来说不起作用.所以我将一个透明图像放在默认状态,它对我有用.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image" android:state_pressed="true"></item>
<item android:drawable="@drawable/image" android:state_selected="true"></item>
<item android:drawable="@drawable/image" android:state_focused="true"></item>
<item android:drawable="@drawable/imagetrans"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
用法:-
<TextView
android:id="@+id/txtobject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:clickable="true"
android:drawableRight="@drawable/selector"
android:focusableInTouchMode="true"
android:text="@string/object"
android:textSize="25sp" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3240 次 |
| 最近记录: |