繁体   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