我有一个RelativeLayout,就像这样:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/favoriteLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background1"
>
....
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background2"
android:layout_below="@+id/linearLayout1"
>
....
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background3"
android:layout_below="@+id/linearLayout2"
>
....
</LinearLayout>
</RelativeLayout>
我想在三个LinearLayout中分别设置不同的背景图像,这些图像应该按比例缩放以填充其LinearLayout,不保留图像的宽高比。同时,我不希望每个LinearLayout都被缩放以适应图像的大小(如果图像高度大于LinearLayout,则希望图像高度减小)。
下面是期望效果: 有人知道如何实现吗?
谢谢!