Android gridview 點擊 顏色 XML設定

Android gridview 點擊 顏色 XML設定

Android gridview 點擊 顏色 XML設定


 

資料來源:http://www.tqcto.com/article/mobile/136423.html

http://blog.csdn.net/top_code/article/details/13601625

http://www.lxway.com/896480646.htm (案例來源)

 

GridView.xml

  <?xml
version=”1.0″ encoding=”utf-8″ ?>

  <GridView xmlns:android=”http://schemas.android.com/apk/res/android android:id=”@+id/gridview
android:layout_width
=”fill_parent android:layout_height=”fill_parent android:numColumns=”2 android:verticalSpacing=”2dp android:horizontalSpacing=”2dp
android:stretchMode
=”columnWidth android:gravity=”center android:background=”#11 android:listSelector=”@drawable/grid_view_item_selector_xml” />

 

 

grid_view_item.xml

<?xml
version=”1.0″ encoding=”utf-8″
?>

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android android:layout_height=”wrap_content android:paddingBottom=”2dip android:layout_width=”fill_parent android:background=”@drawable/grid_view_item_selector_xml“>

  <ImageView android:layout_height=”wrap_content android:id=”@+id/ItemImage android:layout_width=”wrap_content android:layout_centerHorizontal=”true” />

  <TextView android:layout_width=”wrap_content android:layout_below=”@id/ItemImage android:layout_height=”wrap_content android:text=”TextView01 android:layout_centerHorizontal=”true android:id=”@+id/ItemText
/>

  </RelativeLayout>

 

 

grid_view_item_selector_xml.xml

<?xml
version=”1.0″ encoding=”utf-8″
?>

<selector xmlns:android=”http://schemas.android.com/apk/res/android“>

  <item android:state_pressed=”true android:drawable=”@drawable/grid_view_item_press_shape” />

  <item android:drawable=”@drawable/grid_view_item_shape” />

  </selector>

 

 

grid_view_item_press_shape.xml

<?xml
version=”1.0″ encoding=”utf-8″
?>

<shape xmlns:android=”http://schemas.android.com/apk/res/android“>

  <solid android:color=”#5500ffff” />

  </shape>

 

 

grid_view_item_shape.xml

<?xml
version=”1.0″ encoding=”utf-8″
?>

<shape xmlns:android=”http://schemas.android.com/apk/res/android“>

  <solid android:color=”#fff” />

  </shape>

 

 


 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *