您的位置:首页 > 移动开发 > Android开发

Android 让RelativeLayout布局中的控件居中显示

2018-01-03 13:04 661 查看
在RelativeLayout布局中,想让一个控件水平居中,手动设置该控件的layout_width和layout_height为具体的数值,比如:

android:layout_width="130dp"
android:layout_height="130dp"

然后设置android:layout_centerHorizontal="true"
比如想让一个图片水平居中:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dip"
android:layout_margin="15dip">

<ImageView
android:id="@+id/showImg"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:focusableInTouchMode="true"
android:src="@drawable/xiaohui" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: