Android layout 使用图像视图和标题缩放相对值
我有一个带有图像视图和与图像重叠的标题的RelativeLayout 此布局位于另一个RelativeLayout的中心 如有必要,ImageView应缩小比例,但不应增大比例。 在内部使用ScaleType.CENTER_似乎可以做到这一点 如果图像周围有足够的空间(图1,FWVGA),它似乎可以工作 否则,ImageView会变宽,TextView也会随之变宽(图2,WVGA) 我本以为ImageView会缩小比例,保持图像的纵横比 以下是我的布局:--Android layout 使用图像视图和标题缩放相对值,android-layout,Android Layout,我有一个带有图像视图和与图像重叠的标题的RelativeLayout 此布局位于另一个RelativeLayout的中心 如有必要,ImageView应缩小比例,但不应增大比例。 在内部使用ScaleType.CENTER_似乎可以做到这一点 如果图像周围有足够的空间(图1,FWVGA),它似乎可以工作 否则,ImageView会变宽,TextView也会随之变宽(图2,WVGA) 我本以为ImageView会缩小比例,保持图像的纵横比 以下是我的布局:-- 您可以尝试android:sca
您可以尝试
android:scaleType=“fitCenter”
,以适应src
图像。您可以尝试android:scaleType=“fitCenter”
以适应src
图像
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF333333"
android:padding="5dip">
<RelativeLayout
android:layout_height="wrap_content"
android:id="@+id/relativeLayout1"
android:layout_centerInParent="true"
android:layout_width="wrap_content">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ex"
android:scaleType="centerInside"></ImageView>
<TextView
android:background="#AAFFFFFF"
android:textColor="#FF333333"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:text="Caption"
android:layout_alignBottom="@id/imageView"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignLeft="@id/imageView"
android:layout_alignRight="@id/imageView"
android:gravity="center"
android:layout_width="wrap_content"></TextView>
</RelativeLayout>
</RelativeLayout>