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个背景图,形成白环黑内的背景,这样既有分割线,又不会影响到圆角