gon*_*ins 3 layout android uibutton webview
我正在努力弄清楚如何使这个简单的布局工作.我想在一排居中的按钮上面放一个webview.如果我指定一个特定的dp,如400dp,我可以看到顶部的webview和屏幕底部的按钮.但是,对于多种屏幕尺寸,这不能很好地扩展.如果我使用"fill_parent",那么我永远不会看到webview下面的按钮.
我只想要一个布局,它总是将按钮放在屏幕的底部(不滚动屏幕),并让webview占据其上方的其余空间.我整体上使用相对布局,因为我想在加载webview时在屏幕中居中显示进度指示器.
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ProgressBar android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Inverse"
/>
<WebView android:layout_width="fill_parent"
android:id="@+id/webview"
android:layout_alignParentTop="true"
android:layout_height="400dp"
android:layout_weight="1">
</WebView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/webview"
>
<Button android:text="Browse"
android:id="@+id/btnBrowse"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/brouse"
android:textSize="9dp"
/>
<Button android:text="Account"
android:id="@+id/btnAccount"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/account"
android:layout_toRightOf="@+id/btnBrowse"
android:textSize="9dp"
/>
<Button android:text="Contact"
android:id="@+id/btnContact"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1.0"
android:drawableTop="@drawable/contact"
android:layout_toRightOf="@+id/btnAccount"
android:textSize="9dp"
/>
<Button android:text="Quote"
android:id="@+id/btnQuote"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/custom"
android:layout_toRightOf="@+id/btnContact"
android:textSize="9dp"
/>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
更新:
我尝试了一些更多的实验,几乎得到了我想要的东西,除了因某些原因按钮位于屏幕顶部!WTF?无论如何,我会尽快尝试你们的一些建议!谢谢!
<?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">
<ProgressBar android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Inverse"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="9.0"
android:layout_alignParentTop="true">
</WebView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
android:layout_alignParentBottom="true"
>
<Button android:text="Browse"
android:id="@+id/btnBrowse"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/brouse"
android:textSize="9dp"
/>
<Button android:text="Account"
android:id="@+id/btnAccount"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/account"
android:textSize="9dp"
/>
<Button android:text="Contact"
android:id="@+id/btnContact"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1.0"
android:drawableTop="@drawable/contact"
android:textSize="9dp"
/>
<Button android:text="Quote"
android:id="@+id/btnQuote"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_alignParentBottom="true"
android:drawableTop="@drawable/custom"
android:textSize="9dp"
/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Ser*_*tov 12
LinearLayout按钮放在屏幕底部.WebView上面LinearLayout.<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ProgressBar android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Inverse" />
<LinearLayout
android:id="@+id/button_panel"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button ... />
<Button ... />
<Button ... />
<Button ... />
</LinearLayout>
<WebView
android:layout_width="fill_parent"
android:id="@+id/webview"
android:layout_above="@id/button_panel"
android:layout_alignParentTop="true"
android:layout_height="fill_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9246 次 |
| 最近记录: |