簡體   English   中英

如何在Android中創建固定布局

[英]How to create fixed layout in Android

我的活動有轉盤,據說應該在中間。 相對於微調器位置,放置按鈕和標簽。

另一個活動有8個按鈕,其中將顯示某些值。 我在所有活動中都使用了RelativeLayout。 我的應用程序可以在Moto G上正常運行,但是在更大的設備上,所有按鈕和微調器的對齊方式都會發生變化。

我想解決這個問題。

如果是RelativeLayout請使用它

android:layout_centerInParent="true"

這將使元素始終粘在設備的中心,而不管設備的大小。 試試吧..

例如:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageButton android:id="@+id/btnSample" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"></ImageButton>

</RelativeLayout>

暫無
暫無

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

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