Мне нужно разместить три элемента внутри RelativeLayout
:
ImageView
с правой стороны с верхним и нижним полямиTextEdit
в левом верхнем углуLinearLayout
в остальной части пространства (ниже заголовка и слева от изображения) Проблема возникает, когда изображение масштабируется в ImageView
. Я хочу, чтобы он соответствовал всей родительской высоте с учетом полей. После масштабирования равномерно, чтобы соответствовать родительской высоте, я хочу, чтобы ImageView
обертывал ширину изображения. Но в результате в ImageView
есть некоторые незаполненные горизонтальные пространства.
Проблема похожа на проблему, решенную здесь. Но в моем случае все тесты с android:adjustViewBounds
и android:scaleTypes
не работали. Я полагаю, что есть проблема из-за полей и использования RelativeLayout.
Вот выдержка из моего xml файла:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@id/albums_slideshow"
android:adjustViewBounds="true"
android:layout_marginTop="71.33dp"
android:layout_marginBottom="88.67dp"
android:scaleType="centerInside"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/music_img_album_noimage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/music_module_screen_title_margin_left"
android:layout_marginTop="@dimen/music_module_screen_title_margin_top"
android:text="@string/music_string"
style="@style/ScreenTitleFont"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="@id/albums_slideshow"
android:layout_toLeftOf="@id/albums_slideshow">
...
</LinearLayout>
</RelativeLayout>
Кто-нибудь встретил эту проблему и нашел ответ?
это то, что я придумал
и это xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView android:id="@+id/album_text"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
android:layout_marginLeft="20dip" android:layout_marginTop="20dip"
android:text="music string" android:background="@android:color/white"
/>
<LinearLayout android:id="@+id/albums_list"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_alignParentLeft="true" android:layout_below="@id/album_text"
android:layout_marginTop="71.33dp"
android:orientation="vertical" android:background="@android:color/white"
>
<TextView android:id="@+id/album_text"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
android:layout_marginLeft="20dip" android:layout_marginTop="20dip"
android:text="albums list"
/>
</LinearLayout>
<ImageView android:id="@+id/albums_slideshow"
android:layout_height="fill_parent" android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="88.67dp"
android:layout_alignTop="@id/albums_list"
android:scaleType="centerInside"
android:layout_centerInParent="true" android:background="@android:color/darker_gray"
android:src="@drawable/icon"/>
</RelativeLayout>
сообщите мне об улучшениях