当前位置:
首页 >
GridView 添加分害线
发布时间:2023/12/20
39
豆豆
生活随笔
收集整理的这篇文章主要介绍了
GridView 添加分害线
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
GridView没有setDivider方法,添加分割线时只能用spacing方法,但是这与圆角的GridView背景会冲突,百度google无果自己解决 (分割线是不通到边的)
String[] sc = scope.split(",");//when sc is not times 3, make it times 3.int rowNUM = (sc.length%3)==0? sc.length/3: sc.length/3+1 ;String[] sc3 = new String[rowNUM*3];for(int ji=0;ji<rowNUM*3;ji++){if(ji<sc.length){sc3[ji] = sc[ji];}else{sc3[ji] = "";}}gv.setNumColumns(3);ArrayAdapter<String> adapter = new ArrayAdapter<String>(ShopMainActivity.this,R.layout.grid1, R.id.grid1_tv, sc3);gv.setAdapter(adapter); <FrameLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginRight="10dp" ><TextViewandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_margin="2dp"android:background="#fff" ></TextView><TextViewandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_margin="6.5dp"android:background="#ccc" ></TextView><GridViewandroid:id="@+id/shop_intro_gridview"android:layout_width="fill_parent"android:layout_height="wrap_content"android:background="@drawable/table_style_trans"android:horizontalSpacing="1dp"android:verticalSpacing="1dp" ></GridView></FrameLayout>思路就是gridview背景透明,让其后叠加2个背景图,形成白环黑内的背景,这样既有分割线,又不会影响到圆角
转载于:https://www.cnblogs.com/linxiaojiang/archive/2013/05/09/3069287.html
总结
以上是生活随笔为你收集整理的GridView 添加分害线的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: android代码设置drawable,
- 下一篇: SVN—创建分支、合并分支到主干