java
view.setBackgroundResource(android.R.drawable.list_selector_background);
view.setBackgroundColor(android.R.attr.selectableItemBackground);
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?android:attr/selectableItemBackground" >
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center" />
</LinearLayout>
drawable/textview_btn_bg.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@android:drawable/btn_default" />
<item android:state_pressed="true"
android:drawable="@android:drawable/btn_default" />
<item android:drawable="@android:color/transparent" />
</selector>
'programmer > android' 카테고리의 다른 글
Using EditText (0) | 2013.06.14 |
---|---|
gridview spacing (0) | 2013.06.11 |
selector setting (0) | 2013.06.11 |
Dialog softkeyboard (0) | 2013.06.10 |
apache 압축 라이브러리를 이용한 압축 클래스 (0) | 2013.05.29 |