支付宝九宫格
Posted Z2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了支付宝九宫格相关的知识,希望对你有一定的参考价值。
<?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); } }
以上是关于支付宝九宫格的主要内容,如果未能解决你的问题,请参考以下文章
Android控件GridView之仿支付宝钱包首页带有分割线的GridView九宫格的完美实现