标签:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/home_adapter_item" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="0.0dip" android:background="@color/color_item_grid_bg"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerInParent="true" android:background="@null" android:padding="12.0dip"> <ImageView android:id="@+id/imageView" android:layout_width="30dp" android:layout_height="30dp" android:layout_centerHorizontal="true" /> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/imageView" android:layout_centerHorizontal="true" android:layout_marginTop="5.0dip" android:singleLine="true" android:textColor="#999999" android:textSize="12sp" /> </RelativeLayout> </RelativeLayout>
<?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="#e5e5e5" /> <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="#e5e5e5" /> </shape> </item> <item> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 连框颜色值 --> <item> <shape> <solid android:color="@color/colorLine" /> </shape> </item> <!-- 主体背景颜色值 --> <item android:bottom="1dp" android:left="0dp" android:right="1dp" android:top="0dp"> <shape> <solid android:color="#ffffff" /> </shape> </item> </layer-list> </item> </selector>
mGridView = (com.changim.patient.app.widget.MyGridView) view.findViewById(R.id.girdView); bottomAdapter = new HomeAdapter(getActivity()); mGridView.setAdapter(bottomAdapter);
因为外面嵌套了srcoolView 为了完全展开gridView 所以自定义GridView
package com.changim.patient.app.widget; import android.content.Context; import android.util.AttributeSet; import android.widget.GridView; /** * Created by Administrator on 2016/3/23. */ public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }
标签:
原文地址:http://www.cnblogs.com/zzw1994/p/5346472.html