Il mio layout ha ImageView (iv) e TextView (tv). Voglio lasciare la tv a destra di iv. E l'altezza della tv è uguale a quella di Iv. Il televisore Gravity impostato come CENTER_VERTICAL.Come lasciare la ImageView e la TextView alla stessa altezza
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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" >
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/iv"
android:text="TextView" android:gravity="center_vertical"/>
</RelativeLayout>
Come raggiungere l'obiettivo?
Potete utilizzare LinearLayout invece di RelativeLayout, puoi usare il parametro layout_weight come 1 sia per ImageView che per TextView –
Come avrai la stessa altezza di entrambi i widget? l'altezza del textview dipende dalla dimensione del testo. Possiamo stare solo fianco a fianco, non possiamo garantire le altezze allo stesso modo. –