基本android浏览器的正确布局
我需要为android创建一个基本浏览器:一个WebView,顶部有一个带有后退按钮的工具栏,底部有一个带有更多按钮的工具栏 这样做的最佳方式是什么 这就是我到目前为止所做的:基本android浏览器的正确布局,android,android-layout,android-widget,Android,Android Layout,Android Widget,我需要为android创建一个基本浏览器:一个WebView,顶部有一个带有后退按钮的工具栏,底部有一个带有更多按钮的工具栏 这样做的最佳方式是什么 这就是我到目前为止所做的: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" an
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/browserBackButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back" />
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/back" />
<ImageButton
android:id="@+id/forwardButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/forward" />
<ImageButton
android:id="@+id/reloadButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/reload" />
<ImageButton
android:id="@+id/browserButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/safari" />
</LinearLayout>
</LinearLayout>
按钮的底部线条布局根本不显示。只有上后退按钮和网络视图。就我个人而言,我不喜欢嵌套
线性布局。
当布局变得更复杂时,它可能会影响性能。对于一些小事情来说,这可能不是什么大事;但是,使用RelativeLayouts
仍然是一种很好的做法
另外,丢失xmlns:android=”http://schemas.android.com/apk/res/android“
在第二个线性布局中
。你不需要它
希望这有帮助 线性布局可以
您应该更改WebView
控件的高度,并将权重设置为1
这样做:
<WebView android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent"
<WebView android:layout_height="0dip" android:layout_weight="1" android:layout_width="fill_parent"