组件遮盖。。。。

wyc_ 2015-06-22 09:36:43

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/lang_arrow_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:contentDescription="@string/imagecontent"
android:src="@drawable/arrow_left" />

<HorizontalScrollView
android:id="@+id/lang_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clipChildren="true"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/lang_scroll_con"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">

</LinearLayout>
</HorizontalScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="0dp"
android:contentDescription="@string/imagecontent"
android:src="@drawable/arrow_right" />
</RelativeLayout>

我想要的效果是,两侧的箭头始终在最前端显示,中间的HScrV中的内容可以在下面滑动,为什么这样不可以呢?应该怎样做呢?谢谢
...全文
154 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
風言楓語 2015-06-23
  • 打赏
  • 举报
回复
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/lang_arrow_left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="0dp"
            android:contentDescription="@string/imagecontent"
            android:src="@drawable/arrow_left" />

        <ImageView
            android:id="@+id/lang_arrow_right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="0dp"
            android:contentDescription="@string/imagecontent"
            android:src="@drawable/arrow_right" />

        <HorizontalScrollView
            android:id="@+id/lang_scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_toLeftOf="@id/lang_arrow_right"
            android:layout_toRightOf="@id/lang_arrow_left"
            android:background="#454545"
            android:clipChildren="true"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@+id/lang_scroll_con"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal" >
            </LinearLayout>
        </HorizontalScrollView>
    </RelativeLayout>
这样改 添加android:layout_toLeftOf="@id/lang_arrow_right" android:layout_toRightOf="@id/lang_arrow_left"者两个属性
Arnold9009 2015-06-23
  • 打赏
  • 举报
回复
在xml文件里,把中间的部分放到最前面声明 RelativeLayout中,声明越靠后,显示越靠上,最后声明的在最上层
dienianhua52 2015-06-23
  • 打赏
  • 举报
回复
把两侧的箭头做成背景图,中间滚动视图设置margin让后隐藏滚动条就行了吧
wyc_ 2015-06-23
  • 打赏
  • 举报
回复
引用 3 楼 u012456102 的回复:
正解,不过要加个+,android:layout_toLeftOf="@+id/lang_arrow_right"

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧