的WebView和按钮布局使得隐形按钮 [英] WebView and buttons layout makes buttons invisible
本文介绍了的WebView和按钮布局使得隐形按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经得到了以下布局:
I've got the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Back" />
<Button android:id="@+id/page_number"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="1 / 100" />
<Button android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Next" />
</LinearLayout>
</LinearLayout>
这导致了以下
我如何适应屏幕并停止的WebView推动它们吗?
How do I make the buttons fit the screen and stop the WebView pushing them off?
推荐答案
使用 RelativeLayout的
。包裹RelativeLayout的周围像这样的按钮:
Use RelativeLayout
. Wrap the RelativeLayout around the buttons like this:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Back"
android:layout_alignParentLeft="true" />
<Button android:id="@+id/page_number"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="1 / 100" />
<Button android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Next" />
</RelativeLayout>
的的android:layout_alignParentBottom =真正的
确保按钮总是有足够的空间。
The android:layout_alignParentBottom="true"
makes sure the buttons always have enough space.
考虑使用的RelativeLayout各地的WebView及用途:
Consider using a RelativeLayout around the WebView and use:
android:layout_alignParentTop="true"`
编辑:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<Button android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:layout_alignParentLeft="true" />
<Button android:id="@+id/page_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 / 100"
android:layout_toRightOf="@+id/back" />
<Button android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_toRightOf="@+id/page_number" />
</RelativeLayout>
</RelativeLayout>
这篇关于的WebView和按钮布局使得隐形按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文