zoukankan      html  css  js  c++  java
  • 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);
    <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" >
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="2dp"
                android:background="#fff" >
            </TextView>
    
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_margin="6.5dp"
                android:background="#ccc" >
            </TextView>
    
            <GridView
                android: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个背景图,形成白环黑内的背景,这样既有分割线,又不会影响到圆角

  • 相关阅读:
    操作系统六文件管理
    Educational Codeforces Round 38 (Rated for Div. 2) ABCD
    51nod 1100 斜率最大
    51nod 最小方差
    51nod 1065 最小正子段和
    P1280 尼克的任务
    牛客小白月赛2
    Codeforces Round #210 (Div. 1) B 二分+dp
    江西财经大学第一届程序设计竞赛
    51nod 1596 搬货物
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3069287.html
Copyright © 2011-2022 走看看