I have a listview in inside a RelativeLayout. The size of my relativelayour change according the size of my listview (number of rows). If it has only two rows, the relative layout stays larger. If it has more rows, the relative stays smaller.
This happen only in small devices.
What do I do?
EDIT: CODE BELOW
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_cinza_transparente_98_porcento"
android:orientation="vertical"
tools:context=".AdicionarMarcaModeloActivity" >
<LinearLayout
style="@style/..."
android:layout_width="match_parent"
android:background="@color/cinza_escuro"
android:orientation="vertical" >
<RelativeLayout
style="@style/..."
android:orientation="vertical" >
<TextView
android:id="@+id/labelCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Marca"
android:textColor="@android:color/white"
android:textSize="22sp" />
<ImageView
android:id="@+id/imgCloseMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:src="@drawable/bt_close" />
</RelativeLayout>
<RelativeLayout
style="@style/..."
android:layout_width="match_parent"
android:background="@color/branco_gelo"
android:orientation="vertical" >
<TextView
android:id="@+id/labelSubCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="SELECIONE A MARCA DO SEU VEÍCULO"
android:textColor="@color/cinza_escuro_fontes_cabecalho" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
style="@style/..."
android:layout_width="match_parent"
android:orientation="horizontal" >
<ListView
android:id="@+id/lvMarcaModelo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/line" >
</ListView>
</RelativeLayout>
// Try this way,hope this will help you to solve your problem...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/labelCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Marca"
android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"
android:textSize="22sp" />
<ImageView
android:id="@+id/imgCloseMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_launcher"
android:layout_marginTop="5dp"/>
<TextView
android:id="@+id/labelSubCabecalhoMarcaModelo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="SELECIONE A MARCA DO SEU VEÍCULO"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="5dp">
<ListView
android:id="@+id/lvMarcaModelo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/line" >
</ListView>
</LinearLayout>
</LinearLayout>