在滚动型的底部有两个相同大小的按钮 [英] Two equal sized buttons at bottom of scrollview
本文介绍了在滚动型的底部有两个相同大小的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能为我的生命环绕这个布局我的大脑。我设法让按键在底部,但因为他们是在一个RelativeLayout的,我不能让他们既为50%。以下是我到目前为止得到的,有些code为简化删除:
I can't for the life of me wrap my brain around this layout. I've managed to get the buttons to the bottom but since they are in a relativelayout I can't get them to both be 50%. Here is what I've got so far, with some code removed for simplification:
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dip">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="15px">
<ImageView android:id="@+id/ImageView02"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="15px"
android:layout_gravity="center_vertical|center_horizontal|center"/>
<TextView
android:id="@+id/barcode"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/item_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/release"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/other_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/box_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:id="@+id/add_bt"
android:text="Add to Collection" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:id="@+id/back_bt"
android:text="Go Back" />
</RelativeLayout>
推荐答案
难道他们必须在一个 RelativeLayout的
?我认为它应该在工作中的LinearLayout
:
Do they have to be in a RelativeLayout
? I think it should work in a LinearLayout
:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ScrollView
android:id="@+id/settingsScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
...
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/add_bt"
android:layout_height="42dp"
android:layout_width="wrap_content"
android:layout_weight="1"
android:text="Add to Collection""
/>
<Button
android:id="@+id/back_bt"
android:layout_height="42dp"
android:layout_width="wrap_content"
android:layout_weight="1"
android:text="Go Back"
/>
</LinearLayout>
</LinearLayout>
我已经指定了 layout_height
在DP,但你可以尝试 WRAP_CONTENT
或不同的值。
I've specified a layout_height
in dp, but you could try wrap_content
or a different value.
这篇关于在滚动型的底部有两个相同大小的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文