"这里是的布局代码;
<?xml version=""1.0"" encoding=""utf-8""?>
<LinearLayout xmlns:android=""http://schemas.android.com/apk/res/android""
android:orientation=""vertical""
android:layout_width=""fill_parent""
android:layout_height=""fill_parent"">
<TextView android:text=""@string/welcome""
android:id=""@+id/TextView""
android:layout_width=""fill_parent""
android:layout_height=""wrap_content"">
</TextView>
<LinearLayout android:id=""@+id/LinearLayout""
android:orientation=""horizontal""
android:layout_width=""wrap_content""
android:layout_height=""wrap_content""
android:gravity=""bottom"">
<EditText android:id=""@+id/EditText""
android:layout_width=""fill_parent""
android:layout_height=""wrap_content"">
</EditText>
<Button android:text=""@string/label_submit_button""
android:id=""@+id/Button""
android:layout_width=""wrap_content""
android:layout_height=""wrap_content"">
</Button>
</LinearLayout>
</LinearLayout>
这是什么样子是在左边,希望它看起来就像是在右边。
"
在ScrollView这不起作用,因为这RelativeLayout将重叠ScrollView在页面底部的任何东西。
我使用动态拉伸来修复它FrameLayout:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<!-- content goes here -->
<!-- stretching frame layout, using layout_weight -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<!-- content fixated to the bottom of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- your bottom content -->
</LinearLayout>
</LinearLayout>
</ScrollView>
你应该尝试一个相对的布局。
如果你有一个相对的布局来填充整个屏幕,你应该可以用它android:layout_alignParentBottom来将按钮移动到屏幕的底部。
如果底部的视图没有以相对布局显示,那么上面的布局可能会占用所有的空间。在这种情况下,您可以将视图放置在底部,首先放置在布局文件中,然后将布局的其余部分放在视图的上方android:layout_above。这使得底部视图可以占用尽可能多的空间,其余的布局可以填充屏幕的其余部分。