GridView 添加分害线
生活随笔
收集整理的這篇文章主要介紹了
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—创建分支、合并分支到主干