Установите макс. ширину ImageView как процент ширины ее родителя

Я загружаю навигацию из веб-сайта, где каждый объект имеет заголовок, описание и изображение. Я хочу иметь все заголовки и описания, центрируемые вдоль той же оси.

Я использую следующее расположение для каждого объекта в ListView. Это хорошо работает, когда изображения вдвое менее широки, чем они высоки, но не, если они немного шире - текст идет под изображением.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:orientation="horizontal">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1">
            <TextView
                android:layout_height="wrap_content"
                android:textSize="10pt"
                android:id="@+id/title"
                android:gravity="center_horizontal"
                android:layout_width="fill_parent" />
            <TextView
                android:layout_height="wrap_content"
                android:id="@+id/description"
                android:layout_width="fill_parent"
                android:gravity="center_horizontal" />
        </LinearLayout>
        <View
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:layout_weight="3" />
    </LinearLayout>
    <ImageView
        android:id="@+id/icon"
        android:adjustViewBounds="true"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_height="wrap_content" />
</RelativeLayout>

Действительно ли возможно вынудить изображение остаться в 25% ширины RelativeLayout или меньше?

16
задан Ben L. 11 June 2010 в 17:55
поделиться