簡體   English   中英

所有平板電腦的通用布局

[英]Universal Layout for all tablets

我正在家里做項目,其中左側有4個按鈕,右側有4個按鈕,大小為100 x 100dp。 我使用絕對布局,以便通過給出x和y值將其正確放置在所需位置。

這僅適用於分辨率為800 * 440的7英寸平板電腦。如果我在Samsung Galaxy Tab上安裝了apk或800 * 440以外的任何其他分辨率,則按鈕會隨機放置或以其他較小尺寸放置。

我該如何解決? 使用相對布局或其他布局我無法輸入按鈕尺寸值? 我希望按鈕具有特定大小。

有人可以幫我解決這個問題嗎? 對於任何分辨率的平板電腦,如何將我的按鈕放置在同一位置。

等待你的回復!

謝謝!

這是一個示例,如果您面臨任何問題,則下面的布局始終將按鈕居中,然后您可以問我將如何幫助您。

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:text="Button 1" android:width="100dp"/>

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button1"
    android:layout_alignBottom="@+id/button1"
    android:layout_alignParentRight="true"
    android:text="Button 2" android:width="100dp"/>

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/button1"
    android:text="Button 3" android:width="100dp"/>

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button3"
    android:layout_alignBottom="@+id/button3"
    android:layout_alignParentRight="true"
    android:text="Button 4" android:height="50dp" android:width="100dp"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM