你能中心RelativeLayout的一个按钮? [英] Can you center a Button in RelativeLayout?
本文介绍了你能中心RelativeLayout的一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想中心的相对布局的一个按钮,这可能吗?我试过的严重性和定位功能,但他们没有做任何事情。
I'm trying to center a button in relative layout, is this possible? I've tried the Gravity and Orientation functions but they don't do anything.
推荐答案
尝试
android:layout_centerHorizontal="true"
完全一样,它为我工作:
Exactly like this, it works for me:
<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>
这篇关于你能中心RelativeLayout的一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文