将滚动视图排列在线性布局上方且不重叠
我需要在水平线性布局上方有一个滚动视图。我的根布局是相对布局(但我可以根据您的解决方案更改它)。
看一下:
// +-----------+
// | |
// | A |
// | |
// +-----------+
// | B |
// +-----------+
B 是布局底部的线性菜单,水平居中对齐。
A 包含一些可能与 B 区域重叠的选项。
我的布局 xml (经过简化)是这样的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view1"
android:layout_above="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:visibility="invisible"
android:layout_weight="1">
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view2"
android:layout_above="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:visibility="invisible"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
</LinearLayout>
</RelativeLayout>
我应该怎么做才能避免这种情况?
I need to have a scroll view above a horizontal linear layout. My root layout is relative layout (but I can change it based on your solution).
Look at this:
// +-----------+
// | |
// | A |
// | |
// +-----------+
// | B |
// +-----------+
B is a linear menu at the bottom of layout and aligned horizontally center.
A contains some options that may overlaps B area.
my layout xml (with simplification) is something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view1"
android:layout_above="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:visibility="invisible"
android:layout_weight="1">
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view2"
android:layout_above="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:visibility="invisible"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/bottom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp" >
</LinearLayout>
</RelativeLayout>
What should I do to avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理完这个问题后,我发现我应该使用边距!
解决办法是:
90dp是B区带边距的实际尺寸。
我知道这不是一个真正的解决方案,但它对我来说效果很好,这可能对其他人有帮助。
After dealing with the problem, I figured out that I should use margins!
The solution is:
90dp is the actual size of B area with margins.
I know that this is not a real solution but it works fine for me and this may help someone else.