[英]Adding a button in the button right side of the screen
我有以下 android 布局,它在屏幕上顯示腳趾列表視圖,一個在左側,另一個在右側。
<?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="fill_parent"
android:orientation="horizontal">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/ListView01"/>
<ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="3" android:id="@+id/ListView02"/>
現在我想添加一個顯示在屏幕右下方的按鈕。 誰能幫助我如何做到這一點?
首先刪除線性布局,使用相對布局。對於按鈕使用以下命令
android:layout_alignParentBottom="true"和android:layout_alignParentRight="true "
一個可能的解決方案應該是:添加一個 RelativeLayout 作為根布局,並將按鈕放在具有屬性 layout_below 和 layout_right 的 LinearLayout 之后(LinearLayout 作為參考)。
嘗試使用以下代碼
<?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="horizontal"
android:background="#ffffff"
>
<Button
android:id="@+id/click"
android:layout_width="100dip"
android:layout_height="60dip"
android:text="Click"
android:layout_alignParentRight="true"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ListView02"
android:background="#00ff00"
android:layout_toLeftOf="@+id/click"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ListView01"
android:background="#000000"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/ListView02"
/>
</RelativeLayout>
謝謝迪帕克
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.