Dev/Android
TextView 터치시 색깔 변경 - state_pressed
healthyryu
2018. 5. 2. 15:32
TextView 에 손가락을 터치할때 색깔을 변경하기!
1. Drawable 에 변경할 방식에 맞게 세팅한다.
(여기는 해당 TextView 가 기본 색깔이 검정색이고 누를때 연한 검정색으로 처리)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#80000000"/>
<item android:state_pressed="false" android:color="#000000"/>
</selector>
2. TextViewd의 android:textColor="" 속성에 해당 Drawable 을 넣어준다.
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/position_view"
android:textColor="@drawable/text_click" />
반응형