Error in Android RelativeLayout when wrapping_content -
i have relative layout 2 views. imageview , textview. textview should have same width imageview , below of imageview.
so set them this
<imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview" android:maxwidth="50dp" android:minwidth="50dp" android:layout_centervertical="true" android:layout_torightof=some_other_view android:layout_marginleft="8dp" android:minheight="10dp" /> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/imageview" android:layout_below="@+id/imageview" android:singleline="true" android:text="stuff" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@android:color/white" android:textsize="12dp" android:textstyle="bold" android:layout_margintop="4dp" android:layout_alignright="@+id/imageview" android:gravity="center" />
this works fine long relativlayout set fill_parent. when try wrap_content height of relativlayout, textview jumps on top of imageview... don't mistake. can me?
you need give layout_gravity="center_vertical" property relative layout...
try solution
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:orientation="vertical" > <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview" android:maxwidth="50dp" android:minwidth="50dp" android:layout_centervertical="true" android:layout_torightof=some_other_view android:layout_marginleft="8dp" android:minheight="10dp" /> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/imageview" android:layout_below="@+id/imageview" android:singleline="true" android:text="stuff" android:textappearance="?android:attr/textappearancesmall" android:textcolor="@android:color/white" android:textsize="12dp" android:textstyle="bold" android:layout_margintop="4dp" android:layout_alignright="@+id/imageview" android:gravity="center" /> </relativelayout>
Comments
Post a Comment