下面扩大滚动视图按钮 [英] buttons below expanding scrollview
问题描述
我努力要实现的布局是(我认为)pretty的简单。
The layout I try to implement is (I think) pretty simple.
一个TextView的扩展取决于里面是什么。正下方有两个按钮(确定/取消)。
One TextView expands depending on what is inside. Just below are two buttons (OK/Cancel).
我可以让按键粘在屏幕的底部,并且工作正常。不过,我想有这些按钮的正下方的TextView。 我已经尝试了很多不同的东西,但这里是我的最新布局:
I can make the buttons stick to the bottom of the screen and that works fine. But I would like to have those buttons just below the TextView. I have tried a lot of different things, but here is my latest layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView android:id="@+id/Scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
>
<TextView
android:id="@+id/Text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</ScrollView>
<RelativeLayout android:id="@+id/buttons"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_below="@+id/Scroll"
android:layout_above="@+id/bottom"
>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button android:id="@+id/ButtonOK"
android:layout_height="80dp"
android:layout_width="fill_parent"
android:text="OK"
android:layout_weight="1"/>
<Button android:id="@+id/ButtonCancel"
android:layout_height="80dp"
android:layout_width="fill_parent"
android:text="Cancel"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout android:id="@+id/bottom"
android:layout_height="0px"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
在最后空的LinearLayout是(不成功)试图prevent认为过去在屏幕的底部...
The empty linearlayout at the end is an (unsuccessful) attempt to prevent the view to extend past the bottom of the screen...
在一切我试过了,无论是按钮在屏幕的底部,或还要再过去,当TextView的太大了。
In everything I tried, either the buttons are at the bottom of the screen or they would go past it when the TextView is too big.
下面是什么,我试图做一个素描:
Here is a sketch of what I am trying to do :
推荐答案
时的目标只是有一个滚动区域,占用了整个页面减去在底部采取了一些按钮的数量?
Is the goal just to have a scrollable area that takes up the entire page minus the amount taken up by some buttons at the bottom?
在这种情况下,使用的LinearLayout
在外部层面,利用权重:
In that case, use a LinearLayout
at the outer level and make use of weights:
<LinearLayout
android:layout_height="wrap_content"
orientation="vertical"...>
<ScrollView
android:layout_height="0"
android:layout_weight="1"
.../>
<LayoutWithButtons
android:layout_height="wrap_content"
..../>
</LinearLayout>
这篇关于下面扩大滚动视图按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!