if every imageview's height is wrap_content, why are you expecting them all 
to be the same (when all their sources are different sizes)? 
AdjustViewBounds isnt a magical property :)
the two "inner" imageviews should be match_parent.

it's also a good idea to define scaleType since it has the most relevancy 
when talking about keeping the image ratio.


On Thursday, January 24, 2013 7:43:49 AM UTC-8, Greenhand wrote:
>
> I attached my project as attachment.
> In my project, I would like to arrange a title at the top of my layout. 
> <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"
>     tools:context=".MainActivity"
>     android:orientation="vertical">
>     
>     <RelativeLayout android:layout_width="wrap_content"
>         android:layout_height="wrap_content">
>         <!-- 600*100 -->
>         <ImageView android:id="@+id/bar" 
>             android:layout_width="fill_parent"
>             android:layout_height="wrap_content"
>             android:adjustViewBounds="true"
>             android:src="@drawable/bar"/>
>         <!-- 160*80 center in parent-->
>         <ImageView android:id="@+id/banner" 
>             android:layout_width="wrap_content"
>             android:layout_height="wrap_content"
>             android:adjustViewBounds="true"
>             android:src="@drawable/banner"
>             android:layout_centerInParent="true"/>
>         <!-- 80*40 center in parent-->
>         <ImageView android:id="@+id/banner2" 
>             android:layout_width="wrap_content"
>             android:layout_height="wrap_content"
>             android:adjustViewBounds="true"
>             android:src="@drawable/banner2"
>             android:layout_centerInParent="true"/>
>     </RelativeLayout>
> </LinearLayout>
>  
> The title is composed of three images, bar (blue), banner1 (pink), banner2 
> (green).
> The bar is the title background. 
> Banner1 and banner2 should be put in the center of the background.
> For some constraints, I am not allowed to resize/modify these images.
>  
> The unexpected_result.png is the result when I run my project as 
> attached on a phone with 480px width.
> The result is not what I want.
> I hope the banner1 height is the same as the height of the blue background 
> and keep banner1 ratio, like desired_result.png.
> Besides, I hope the banner2 height is the same as the height of the blue 
> background and keep banner2 ratio, like desire_result2.png.
>  
> In a nutshell, my question is: Is there a way let the images (banner1 and 
> banner2) centered and overlaid on the background and automatically sretch 
> the height to the height of background while keeping their ratio?
>  
> I have tried to set the blue background as the background of the 
> RelativeLayout. Unfortunately, the background cannot maintain its ratio, 
> like ImageView with adjustViewBounds=true.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to