Android 用户界面困难
我的布局非常完美,直到我决定添加滚动视图。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="@+id/scrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/linearLayout1">
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tableLayout1"/>
</LinearLayout>
</ScrollView>
<Button android:layout_width="match_parent" android:id="@+id/button1" android:text="Start" android:layout_height="50dip" android:onClick="getOutput"></Button>
</TableLayout>
我希望按钮保留在屏幕底部,实际上我希望滚动视图占据整个屏幕。仅使用内部表格布局即可正常工作。在图形布局预览中,它看起来像我想要的那样,但当我运行它时却不是。
我希望滚动视图占据整个屏幕,除了按钮之外,我希望按钮位于底部。
My layout was perfect until I decided to add a scrollview.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="@+id/scrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/linearLayout1">
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tableLayout1"/>
</LinearLayout>
</ScrollView>
<Button android:layout_width="match_parent" android:id="@+id/button1" android:text="Start" android:layout_height="50dip" android:onClick="getOutput"></Button>
</TableLayout>
I would like the button to stay at the bottom of the screen, I would actually like the scrollview to take up the entire screen. With just the inner table layout it works fine. In the Graphical Layout preview it looks how I want it, but not when I run it.
I would like the scrollview to take up the whole screen except the button, which I'd like to be at the bottom.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用RelativeLayout或LinearLayout作为根视图。赋予 Button 更多重量。这样 ScrollView 就不会占据全部内容。
you could use RelativeLayout or LinearLayout as Root view. Giving Button more weight. That way ScrollView won't take up the whole thing.
这应该有效
this should work
尝试将 ScrollView fillViewport 属性设置为 true。
Try setting ScrollView fillViewport attribute to true.