IT_ZJYANG 2016-11-03 13:20 采纳率: 0%
浏览 1642
已结题

Android开发中HorizontalScrollView在滑动时如何做到不影响页面中其他元素

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滑动归它自己滑动,不影响页面中其他元素,急~

  • 写回答

3条回答 默认 最新

  • devmiao 2016-11-03 14:14
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题