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

  • 相关阅读:
    [MySQL] InnoDB三大特性之 插入缓冲
    字节对齐《c和指针》笔记包含位域结构体的内存对齐(32bit,GCC)
    反编译想到的代码安全问题
    剪切\编辑歌曲软件
    照片行【生活随笔】井冈山之行
    埃里克食品浅谈垃圾食品
    C++ 堆排序实现
    SQLite数据库
    全光网络的前世今生
    hdu1201(从出生长18岁经过多少天)
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3069287.html
Copyright © 2011-2022 走看看