How To Let The Imageview And The Textview The Same Height
Solution 1:
hi try this .....
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/RelativeLayout1"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><ImageViewandroid:id="@+id/iv"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:src="@drawable/ic_title_home_demo" /><TextViewandroid:id="@+id/tv"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBottom="@+id/iv"android:layout_alignTop="@+id/iv"android:layout_toRightOf="@+id/iv"android:gravity="center_vertical"android:text="TextView" /></RelativeLayout>
Solution 2:
You have to set the textview property to android:layout_alignTop="@id/iv"
and android:layout_alignBottom="@id/iv"
Solution 3:
Well to get it to center vertically correct, you will need to remove the android:layout_alignParentTop="true"
line from your TextView tag.
However, it sounds like you might be trying to make the text change its size to fit the entire height of the ImageView. This obviously won't solve that, but I wouldn't recommend doing that in the first place as it could result in some strange looking views.
Solution 4:
You can use distinct sizes by using
android:layout_width="wrap_content"
and /or
android:height="300dp"
(same for height). Also check margins and paddings.
If you need to be more dynamic, you might consider android:layout_weight i.e. for letting 2 buttons have equal width and fill the horizontal space of the parent view you would set:
android:layout_height="wrap_content"
android_layout:weight="0.5".
you can follow this link: How to make two different layout to have same height?
Post a Comment for "How To Let The Imageview And The Textview The Same Height"