我要实现这种界面效果
可以左右滑动
我的方法是HorizontalScrollView包裹GridView左右滑动前面添加一个imageview来实现
可以实现滑动,但是效果不对....
实际效果是前面的 imageview 不会显示,必须向右拖动才能显示, 我想要的效果是刚出来就显示那个imageview的,但是实际上不会那样显示我的主要代码为:
求助各位大神我该怎么改?
![](http://img.bbs.csdn.net/upload/201605/11/1462939775_295390.png)
可以左右滑动
我的方法是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);
求助各位大神我该怎么改?