HorizontalScrollView包裹GridView左右滑动但是GridView前面需要有一个imageview怎么实现

我要实现这种界面效果

可以左右滑动
我的方法是HorizontalScrollView包裹GridView左右滑动前面添加一个imageview来实现
<HorizontalScrollView
                android:id="@+id/hl_user_photo"
                android:layout_width="match_parent"
                android:layout_height="@dimen/height_348"
                android:layout_marginLeft="@dimen/margin_36"
                android:paddingBottom="@dimen/margin_32"
                android:scrollbars="none">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal"
                    >

                    <ImageView
                        android:id="@+id/first_image"
                        android:layout_width="167dp"
                        android:layout_height="match_parent"
                        android:layout_alignParentTop="true"
                        android:scaleType="centerCrop"
                        android:src="@drawable/picture_moren" />

                    <LinearLayout
                        android:id="@+id/id_gallery"
                        android:layout_marginLeft="7dp"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="horizontal">

                        <GridView
                            android:id="@+id/gridview"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:columnWidth="81dp"
                            android:horizontalSpacing="5dp"
                            android:verticalSpacing="5dp"></GridView>
                    </LinearLayout>
                </LinearLayout>
            </HorizontalScrollView>

可以实现滑动,但是效果不对....
实际效果是前面的 imageview 不会显示,必须向右拖动才能显示,  我想要的效果是刚出来就显示那个imageview的,但是实际上不会那样显示我的主要代码为:
mHlUserPhoto = (HorizontalScrollView) findViewById(R.id.hl_user_photo);
        gridView = (GridView) findViewById(R.id.gridview);
        mGallery = (LinearLayout) findViewById(R.id.id_gallery);
        mInflater = LayoutInflater.from(this);
adapter = new GridViewAdapter(mImgIds, mGallery, mInflater);
        gridView.setAdapter(adapter);

        int size = mImgIds.length;
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        float density = dm.density;

        int columnsNum = size % 2 == 0 ? size / 2 : size / 2 + 1;
        int allWidth = (int) (86 * columnsNum * density);
        //int itemWidth = (int) (85 * density);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                allWidth, LinearLayout.LayoutParams.MATCH_PARENT);


        gridView.setLayoutParams(params);
        //gridView.setColumnWidth(itemWidth);
        //gridView.setHorizontalSpacing(10);
        gridView.setStretchMode(GridView.NO_STRETCH);
        gridView.setNumColumns(columnsNum);


求助各位大神我该怎么改?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值