Q:

How to wrap a layout to its views without exceeding a fixed size?

I am using this layout in order to have three fixed views:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:textColor="#372c24" 
        android:paddingLeft="10dp"/>

    <View
        android:id="@+id/space"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:background="@android:color/transparent" />

    <LinearLayout
        android:id="@+id/ratingLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="horizontal" 
        android:background="@drawable/shape_popup">
        <TextView
            android:id="@+id/rateNumber"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:gravity="center_horizontal"
            android:paddingTop="2dp" 
          />
        <ImageView
            android:contentDescription="@string/app_name"
            android:id="@+id/rateStar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:layout_gravity="center_horizontal"
            android:src="@drawable/rate_star"/>
    </LinearLayout>

</LinearLayout>

I want my ratingLayout to wrap its content but not to exceed its fixed size. Is that possible?

A:

Remove the weighting on the ratingLayout, and set the rateNumber and rateStar views' layout_width property to "wrap_content" instead of "match_parent".

