custom action bar relative layout children not pla

2019-09-16 15:06发布

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>

1条回答
干净又极端
2楼-- · 2019-09-16 16:13

Remove, android:layout_centerInParent="true" from animals_view_title and add android:layout_centerVertical="true" to it.

查看更多
登录 后发表回答