0
아래 코드를 사용하여 안내 해주세요. 내 문제는 입니다. TextView의 "눌림"상태가 표시되지 않습니다. 구현할 수 있습니까? TextView의 눌림 상태? 내가 어떻게 할?안드로이드 - TextView 백그라운드 색상이 다른 상태로 변경되었습니다.
다음 코드를 사용하여 성공했지만 TextView에 성공하지 못했습니다.
pls는 저에게 안내
내 버튼 및 텍스트 뷰 코드 :
<Button
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@drawable/button_state"
android:padding="20dp">
</Button>
<TextView
android:text="Demo of Color on state change"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@drawable/button_state"
android:focusable="true">
</TextView>
button_state.xml
파일 (내가 당김 폴더에 저장 한) :
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient
android:startColor="@color/yellow1"
android:endColor="@color/yellow2"
android:angle="270" />
<stroke
android:width="3dp"
android:color="@color/grey" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:endColor="@color/orange1"
android:startColor="@color/orange2"
android:angle="270" />
<stroke
android:width="3dp"
android:color="@color/grey" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:endColor="@color/blue1"
android:startColor="@color/blue2"
android:angle="270" />
<stroke
android:width="3dp"
android:color="@color/grey" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
color.xml
파일 :
<resources>
<color name="yellow1">#FFFF99</color>
<color name="yellow2">#FFCC00</color>
<color name="orange1">#FF9966</color>
<color name="orange2">#FF6600</color>
<color name="blue1">#99CCFF</color>
<color name="blue2">#0033CC</color>
<color name="grey">#736F6E</color>
</resources>
나는 동일한 주제로 SO에 대한 질문을했지만 유용하지는 않습니다. http://stackoverflow.com/questions/4336218/android-textview-change-color-on-changing-of-state –