I need to place three elements inside RelativeLayout
:
- scaled image in
ImageView
on the right side with the top and bottom margins TextEdit
in the left top cornerLinearLayout
in the rest of the space (below the title and to the left of the image)
The problem happens when the image is scaled in ImageView
. I want it fits the entire parent's height considering margins. After scaling uniformly to fit the parent's height I want ImageView
wraps the image's width. But as the result there are some unfilled horizontal spaces in ImageView
.
The problem looks similar to one solved here. But in my case all tests with android:adjustViewBounds
and android:scaleTypes
didn't work. I suppose there is a problem because of margins and RelativeLayout use.
Here is th开发者_如何学Ce extract from my xml file:
<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>
Has anyone met this problem and found the answer?
this is what i have come up with
and this is the 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>
let me know for improvements
精彩评论