我正在尝试使按钮在相对布局中居中,这可能吗?我已经尝试过重力和方向功能,但它们什么也没做。
最佳答案
试试
android:layout_centerHorizontal="true"
正是这样,它对我有用:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000">
<Button
android:id="@+id/btn_mybutton"
android:layout_height="wrap_content"
android:layout_width="124dip"
android:layout_marginTop="5dip"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
关于android - 你可以在RelativeLayout中居中一个按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3748255/