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" />
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" />
相关文章推荐
- android 布局: LinearLayout如何使TextView中的内容居中显示
- Android:控件布局(相对布局)RelativeLayout RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列。 相对布局常用属性: 子类控件相对子
- android Relativelayout 某控件设置layout_alignParentRight=true,整行不显示问题
- DevExpress 在LayoutControl中放置控件保持布局居中显示
- RelativeLayout中两个控件怎么居中显示
- Android 自定义布局控件-圆形RelativeLayout
- android RelativeLayout里两控件间居中
- Android UI控件系列:RelativeLayout(相对布局)
- Android:控件布局(相对布局)RelativeLayout
- Android:控件布局(相对布局)RelativeLayout(转)
- Android常用布局控件之RelativeLayout
- LinearLayout布局中控件居中显示
- (10)Android布局控件之RelativeLayout详解
- Android布局控件之RelativeLayout详解
- Android布局之FrameLayout设置控件居中显示
- Android布局控件之RelativeLayout详解
- Android布局控件之RelativeLayout详解
- RelativeLayout中两个控件怎么居中显示?
- 控件悬浮在某个控件之上 Android五大布局方式——相对布局(RelativeLayout)属性详解
- android 布局: LinearLayout如何使TextView中的内容居中显示