本文介绍了自定义操作栏相对布局的孩子放置不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的RelativeLayout的创建自定义的操作栏。问题是, height_indicator
没有显示到 animals_view_title
的权利。相反,他们出现叠加:既在中心。现在,在图形布局,它看起来是正确的。但是,当我在我的S4运行失败。
< RelativeLayout的
机器人:ID =@ + ID / my_rel_view
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:主题=@风格/ CustomTheme
机器人:能见度=有形与GT;
<的TextView
机器人:ID =@ + ID / animals_view_title
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerInParent =真
机器人:layout_marginRight =10dp
机器人:文本=动物
机器人:文字颜色=#DDDDDDDD
机器人:TEXTSIZE =26sp/>
<的TextView
机器人:ID =@ + ID / height_indicator
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerVertical =真
机器人:layout_toRightOf =@ ID / animals_view_title
机器人:drawableRight =@可绘制/ height_unit
机器人:文本=0
机器人:文字颜色=#FFFFFF
机器人:TEXTSIZE =10SP/>
< ImageView的
机器人:ID =@ + ID / edit_btn
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_centerVertical =真
机器人:layout_marginRight =5DP
机器人:layout_marginTop =15dp
机器人:可点击=真
机器人:的onClick =editHeight
机器人:SRC =@可绘制/ edit_button/>
< / RelativeLayout的>
解决方案
删除,安卓layout_centerInParent =真正的
从 animals_view_title
并添加安卓layout_centerVertical =真正的
给它。
I am using the following RelativeLayout to create a custom action bar. The problem is that height_indicator
is not showing to the right of animals_view_title
. Instead, they appear superimposed: both at the center. Now on the Graphical Layout it looks correct. But when I run it on my S4 it fails.
<RelativeLayout
android:id="@+id/my_rel_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/CustomTheme"
android:visibility="visible" >
<TextView
android:id="@+id/animals_view_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:text="The Animals"
android:textColor="#DDDDDDDD"
android:textSize="26sp" />
<TextView
android:id="@+id/height_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/animals_view_title"
android:drawableRight="@drawable/height_unit"
android:text="0"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<ImageView
android:id="@+id/edit_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:clickable="true"
android:onClick="editHeight"
android:src="@drawable/edit_button" />
</RelativeLayout>
解决方案
Remove, android:layout_centerInParent="true"
from animals_view_title
and add android:layout_centerVertical="true"
to it.
这篇关于自定义操作栏相对布局的孩子放置不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!