Android GirdView
来源:互联网 发布:软件行业市场调查问卷 编辑:程序博客网 时间:2024/06/07 21:39
笔者在用GridView时发现GridView的select style会根据系统而不同,因为在客户端中一边具有统一的显示风格,所以尝试了下指定GridView的选中样式。
首先看一下代码:
menu.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#e1e7e8"
- android:orientation="vertical">
- <include android:id="@+id/menu_title" layout="@layout/title" />
- <GridView android:listSelector="#e1e7e8"
- android:id="@+id/menu" android:layout_width="fill_parent" android:layout_marginTop="10dip"
- android:layout_height="fill_parent" android:numColumns="auto_fit"
- android:verticalSpacing="10dp" android:horizontalSpacing="10dp"
- android:columnWidth="90dp" android:stretchMode="columnWidth"
- android:gravity="center">
- </GridView>
- </LinearLayout>
menuitem.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="4dip"
- android:background="@drawable/bg_alibuymenu_states"
- android:layout_width="fill_parent">
- <ImageView android:layout_height="wrap_content"
- android:id="@+id/ItemImage"
- android:layout_marginTop="20dip"
- android:layout_width="wrap_content"
- android:layout_centerHorizontal="true">
- </ImageView>
- <TextView android:layout_width="wrap_content"
- android:gravity="center"
- android:textColor="@color/text_color"
- android:singleLine="true"
- android:textSize="16dip"
- android:layout_below="@+id/ItemImage"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:id="@+id/ItemText">
- </TextView>
- </RelativeLayout>
android:background="@drawable/bg_alibuymenu_states"这句话指定了 GridView中的元素的背景风格。
bg_alibuymenu_states.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/bg_alibuybutton_selected" />
- <item android:state_focused="true" android:drawable="@drawable/bg_alibuybutton_selected" />
- </selector>
bg_alibuybutton_selected.xml
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
- <corners android:radius="3dp" />
- <stroke android:width="0.5dp" android:color="#62809a" />
- <gradient android:startColor="@color/button_selected_start_color"
- android:endColor="@color/button_selected_end_color" android:type="linear"
- android:angle="90" android:centerX="0.5" android:centerY="0.5" />
- </shape>
bg_alibuybutton_default.xml
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
- <corners android:radius="3dp" />
- <stroke android:width="0.5dp" android:color="#62809a" />
- <gradient android:startColor="@color/button_defalut_start_color"
- android:endColor="@color/button_defalut_end_color" android:type="linear"
- android:angle="90" android:centerX="0.5" android:centerY="0.5" />
- </shape>
出处:http://blog.csdn.net/weich_java/article/details/6987198
- Android GirdView
- Android入门/GirdView(九)
- android笔记6-GirdView
- android-----GirdView的使用
- Android网格布局(GirdView)学习
- Android--GirdView下拉刷新功能
- Android二级分类列表GirdView
- android手机卫士06-girdview优化
- Android:GirdView实现九宫格的代码
- Android GirdView 最后一行显示不完整
- Android GirdView写出TabActivity而已更加具有可定制性
- android scrollview嵌套girdview显示效果不理想的问题解决
- Android GirdView/Listview 最后一行显示不完整
- Android二级分类列表ListView GirdView in ViewPager
- Android:RecyclerView详解(ListView,GirdView,瀑布流)
- Android GirdView/Listview 最后一行显示不完整
- Android低阶 【chapter-7】GirdView和ListView常用的东西
- Android girdView/listView item 高度设置无效的解决方法
- 深入分析DWREngine._stateChange
- openprocess失败,errorcode为5,提权代码
- 第十周实验报告2
- QT/信号和槽(酷勤网)
- [面经]百度商业搜索部实习面试经历
- Android GirdView
- C++笔记1
- Android中TextView中文字死活不滚的解决办法
- 分享来自zoomla!逐浪CMS的.net十个优势
- android 界面布局 很好的一篇总结 【转】
- 电容在电路中的作用
- hdu1544
- 第10周任务1
- 第十周实验报告2