xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="260dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="130dp"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@drawable/bg_space"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="260dp"
android:background="#ffbbaa">
<HorizontalScrollView
android:id="@+id/horizontal_scrollview"
android:layout_width="wrap_content"
android:layout_height="260dp"
android:background="@color/black"
>
<LinearLayout
android:id="@+id/custom_scroller_llyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:scrollbars="none">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
如上布局代码,当HorizontalScrollView中的子控件添加的比较多时,HorizontalScrollView的宽度会超出屏幕并且开始能够滑动,但是我在滑动HorizontalScrollView的时候,页面中其他不属于HorizontalScrollView的元素也会受它的影响,就比如上面代码中的linear这个LinearLayout也会跟着一块滑动,这不是我想要的效果。
有尝试过去限定HorizontalScrollView的宽度,然而一限定,它就失去了滑动效果。
求问有没有办法让其不受影响,HorizontalScrollView滑动归它自己滑动,不影响页面中其他元素,急~