关于RelativeLayout设置垂直居中对齐不起作用的问题
2014-11-16 23:27
302 查看
直接上代码
1.原有代码:(红色字体部分不起作用,无法让RelativeLayout中的textview居中)
<RelativeLayout
android:id="@+id/autoquery_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<TextView
android:id="@+id/autoquery_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/autoquery_tip"
/>
</RelativeLayout>
2.正确代码:(同样注意红色字体)
<RelativeLayout
android:id="@+id/autoquery_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/autoquery_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/autoquery_tip"
/>
</RelativeLayout>
如此设置即可让textview居中了。
1.原有代码:(红色字体部分不起作用,无法让RelativeLayout中的textview居中)
<RelativeLayout
android:id="@+id/autoquery_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<TextView
android:id="@+id/autoquery_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/autoquery_tip"
/>
</RelativeLayout>
2.正确代码:(同样注意红色字体)
<RelativeLayout
android:id="@+id/autoquery_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/autoquery_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/autoquery_tip"
/>
</RelativeLayout>
如此设置即可让textview居中了。
相关文章推荐
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- 关于RelativeLayout设置垂直居中对齐不起作用的问题
- CoordinatorLayout中设置layout_behavior的布局无法垂直居中问题解决
- Android中RelativeLayout的字符水平(垂直居中)对齐
- 关于CSS制作水平/垂直居中对齐问题
- RelativeLayout里面各个控件对齐问题
- 关于RelativeLayout的一个奇怪问题
- RelativeLayout中使用include标签对齐不起作用解决方法
- CSS关于元素垂直居中的问题
- android程序在Layout中设置控件水平或垂直居中
- 关于iOS中设置UIButton的标题(含图)左右对齐的问题
- 关于div+css设置居中问题
- RelativeLayout中放置两个控件后不能居中的问题
- Android关于LinearLayout和RelativeLayout背景设置的区别
- 奇葩2: storyboard中使用AutoLayout,设置Label居中,但不起作用
- 表单元素和文字垂直居中对齐的问题