Android GridView分隔线实现

 参考:http://blog.csdn.net/jdsjlzx/article/details/44182693

直接上代码不多说:

GridView界面视图:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:orientation="vertical" >

    <GridView
        android:id="@+id/ble_gridview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
       
        android:numColumns="2"
        android:stretchMode="columnWidth"
        android:smoothScrollbar="true"
        android:listSelector="@null" 
        android:verticalSpacing="0px" 
        android:horizontalSpacing="0px"
        android:soundEffectsEnabled="true"
        
         >
    </GridView>

</LinearLayout>


适配器视图界面(其中 ScrollingTextView可改为TextView ):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/gridview_divider"
        android:orientation="vertical"
         >

        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="115dp"
            android:layout_gravity="center"
            android:scaleType="center" />

        <bluetoothsoc.serialport.view.ScrollingTextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:gravity="center"
            android:singleLine="true"
            
            android:marqueeRepeatLimit="marquee_forever"
            android:focusableInTouchMode="true"
            android:textColor="@android:color/white"
            android:textSize="32dp" />
    </LinearLayout>

</RelativeLayout>


gridview_divider.xml
<?xml version="1.0" encoding="utf-8"?>  
<selector xmlns:android="http://schemas.android.com/apk/res/android">  
  
    <item android:state_pressed="true"><shape android:shape="rectangle">  
            <stroke android:width="1.0px" android:color="@android:color/white" />  
  
            <gradient android:angle="270.0" android:endColor="#ffe8ecef" android:startColor="#ffe8ecef" />  
        </shape></item>  
    <item android:state_focused="true"><shape android:shape="rectangle">  
            <gradient android:angle="270.0" android:endColor="#ffe8ecef" android:startColor="#ffe8ecef" />  
  
            <stroke android:width="1.0px" android:color="@android:color/white" />  
        </shape></item>  
    <item><shape android:shape="rectangle">  
            <gradient android:angle="270.0" android:endColor="#000000" android:startColor="#000000" />  
  
            <stroke android:width="1.0px" android:color="@android:color/white" />  
        </shape></item>  
  
</selector>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值