0
我的佈局中恰好有5個按鈕。我在顯示佈局時遇到的問題是 - 佈局的剩餘空間被浪費,而不是空的。我想縮小屏幕尺寸,使其看起來沒有半邊空白。調整Android中的佈局
以下是代碼我已經寫在XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<!-- I want to eat button -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/iWantToEat"
android:textSize="20sp" android:id="@+id/iWantToEat">
</Button>
<!-- Categories -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/Categories"
android:textSize="20sp" android:id="@+id/Categories">
</Button>
<!-- Explore/Discover -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/Explore"
android:textSize="20sp" android:id="@+id/Explore">
</Button>
<!-- Search -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/Search"
android:textSize="20sp" android:id="@+id/Search">
</Button>
<!-- My Favorites -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/myFavourites"
android:textSize="20sp" android:id="@+id/myFavourites">
</Button>
</LinearLayout>
有沒有辦法實現呢?
Adithya。
我不理解......你想要的5個按鈕來填充整個屏幕?? –
no ..我希望只有這些按鈕具有特定尺寸(比如20sp),但希望屏幕尺寸減小,以便佈局僅顯示這5個按鈕,佈局中不會留下空白區,因爲它通常會在下面進行那些按鈕。 – Adithya
所以你可以在按鈕之間有空格... –