/** * * @param context * @param WidthdpValue * @param HeightdpValue * @param mList * @param mGridView * @param ImgType     */public static void setGvdip2px(final Context context, float WidthdpValue, float HeightdpValue, final List mList, GridView        mGridView, final int ImgType) {    int itemWidth =  CommonUtil.dip2px(context, WidthdpValue);    int itemHeight = CommonUtil.dip2px(context, HeightdpValue);    int itemSize = mList.size();    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(itemSize * itemWidth, itemHeight);    mGridView.setNumColumns(itemSize);    mGridView.setLayoutParams(params);    mGridView.setAdapter(new CheckCarImageAdapter(context, mList,ImgType));    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {        @Override        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {            Intent intent = new Intent(context, CircuitryImageActivity.class);            intent.putStringArrayListExtra("LIST", (ArrayList) mList);            intent.putExtra("TYPE", "1");            context.startActivity(intent);        }    });}

<?xml version="1.0" encoding="utf-8"?>    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">                android:id="@+id/ll_spray_paint"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="vertical"        android:paddingLeft="20dp"        android:paddingRight="20dp"        android:paddingTop="10dp"        android:paddingBottom="10dp"        >                    android:layout_width="match_parent"            android:layout_height="wrap_content"            android:gravity="center_vertical"            android:orientation="horizontal">                            android:id="@+id/tv_name"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="" />                            android:layout_weight="1"                android:layout_width="0dp"                android:layout_height="1dp"                />                                       android:id="@+id/tv_option"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="" />                                    android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:padding="5dp">                            android:layout_width="match_parent"                android:layout_height="wrap_content">                                    android:id="@+id/gv_Image"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:horizontalSpacing="10dp"                    android:gravity="center" />                                    android:layout_width="match_parent"        android:layout_height="1dip"        android:background="@drawable/divider"/>
public class CustomeGridView extends GridView {    public CustomeGridView(Context context) {        super(context);    }    public CustomeGridView(Context context, AttributeSet attrs) {        super(context, attrs);    }    public CustomeGridView(Context context, AttributeSet attrs, int defStyle) {        super(context, attrs, defStyle);    }    /**     * 设置上下不滚动     */    @Override    public boolean dispatchTouchEvent(MotionEvent ev) {        //true:禁止滚动        return ev.getAction() == MotionEvent.ACTION_MOVE || super.dispatchTouchEvent(ev);    }    @Override    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {        int expandSpec = heightMeasureSpec;        boolean hasScrollBar = true;        if (hasScrollBar) {            expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,                    MeasureSpec.AT_MOST);            super.onMeasure(widthMeasureSpec, expandSpec);// 直接测量出GridView的高度        } else {            super.onMeasure(widthMeasureSpec, heightMeasureSpec);        }    }}



更多相关文章

  1. android监听音量上下键调节音量
  2. Android(安卓)Menu 菜单用法 一看就懂
  3. android绘制view的过程(自定义view一)
  4. Android滚动加载数据
  5. Android艺术开发探索第四章——View的工作原理(上)
  6. android webkit JavaScript 不能处理onkeydown的上下左右键,引发
  7. Android中onContextItemSelected不响应
  8. scrollview 滚动条
  9. Android的ListView数据更新后,如何使最新的条目可以自动滚动到可

随机推荐

  1. 来点基础的--诡异的极客们的符号--流、管
  2. Linux Box上运行哪个SQL服务器?
  3. linux中创建公私钥
  4. 报告节选3:Linux比例近半 操作系统混战虚
  5. 继续问linux下c问题
  6. 嵌入式Linux系统工程师系列之ARM920T的MM
  7. find . -type f ! -name "*.o" 排除某类
  8. 解决找不到动态库libpthread.so
  9. PHP通过SSH操作远程服务器(linux)
  10. Linux和Windows下重启MySQL方法--方便查