Android:RelativeLayout的滚动视图阻止按钮
我的应用程序当前看起来如下所示: 当我点击Android:RelativeLayout的滚动视图阻止按钮,android,layout,scrollview,Android,Layout,Scrollview,我的应用程序当前看起来如下所示: 当我点击按钮时,边框颜色变为绿色,如上图所示。我为我的单词列表添加了一个scrollview,如图右侧所示。问题是这个滚动视图几乎覆盖了整个屏幕,我无法点击按钮的前三行 布局的简要说明: 我创建了一个相对布局。25个按钮在此相对布局中。然后在相对布局中我创建了一个可滚动线性布局包含20个文本视图 有人能帮我修一下这个布局吗?我希望能够单击所有按钮,并使滚动视图不阻止按钮 我认为将25个按钮放在主相对布局中自己的相对布局可能是个好主意。有人知道我如何不用重做整个
按钮时,边框颜色变为绿色,如上图所示。我为我的单词列表添加了一个scrollview
,如图右侧所示。问题是这个滚动视图几乎覆盖了整个屏幕,我无法点击按钮的前三行
布局的简要说明:
我创建了一个相对布局
。25个按钮
在此相对布局中。然后在相对布局中
我创建了一个可滚动
线性布局
包含20个文本视图
有人能帮我修一下这个布局吗?我希望能够单击所有按钮
,并使滚动视图
不阻止按钮
我认为将25个按钮
放在主相对布局
中自己的相对布局
可能是个好主意。有人知道我如何不用重做整个布局就能做到这一点吗
另外,如果你们对如何正确编码布局有任何建议,请告诉我。我对android编程相当熟悉,不知道是否应该使用相对布局
vs线性布局
vs框架布局
或匹配父项
vs填充父项
vs包装内容
。如果我滥用了其中任何一种,请告诉我
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Game" >
<Button
android:id="@+id/button1"
android:layout_width="@dimen/size"
android:layout_height="@dimen/size"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="18dp"
android:background="@drawable/button"
android:onClick="ButtonOnClick" />
.
. (Buttons 2 - 24)
.
<Button
android:id="@+id/button25"
android:layout_width="@dimen/size"
android:layout_height="@dimen/size"
android:layout_alignBaseline="@+id/button24"
android:layout_alignBottom="@+id/button24"
android:layout_alignLeft="@+id/button20"
android:background="@drawable/button"
android:onClick="ButtonOnClick" />
<ScrollView
android:id="@+id/scrollable"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scrollbars="vertical" >
<LinearLayout
android:id="@+id/ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="300dp"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/word1" />
.
. (TextViews 2 - 19)
.
<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/word20" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
.
. (按钮2-24)
.
.
. (文本视图2-19)
.
使用线性布局而不是相对布局作为顶部布局,并使其成为android:orientation=“horizontal”
然后将所有按钮放在一个带有android:layout\u weight=“1”和android:layout\u width=“0dp”的相对位置
另外,将ScrollView放在第二个RelativeLayout中,宽度为“wrap_content”
结构如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_widtht="0dp"
android:layout_heigh="fill_parent"
android:layout_weight="1">
All buttons go here...
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent">
Scroll view goes here...
</RelativeLayout>
</LinearLayout>
所有按钮都在这里。。。
滚动视图转到这里。。。
将按钮置于另一个相对布局中,并将scrollview置于其右侧。只是一个建议,试一试。哈,实际上我在我的帖子中建议这么做。我正在尝试,但它不起作用。你能发布你的整个xml吗,这样我就可以试试了。我已经复制了一部分,但需要做很多修改。哦,没关系。我是根据大家的建议想出来的。谢谢