Android 以不同分辨率缩放图像

Android 以不同分辨率缩放图像,android,xml,scaling,resolutions,Android,Xml,Scaling,Resolutions,我创建了4个分辨率文件夹,并将适当的图像大小放入其中,如下图所示: 我还为不同的屏幕大小创建了8个不同的布局文件夹,如下图所示: 如下图所示,我需要根据每个XML文件重新调整图像的大小,以便它们填满屏幕: 我使用此代码缩小图像,效果很好: android:adjustViewBounds="true" android:maxWidth="150dp" android:scaleType="fitCenter" 但我不知道如何放大图像。我一直在尝试使用以下代码: an

我创建了4个分辨率文件夹,并将适当的图像大小放入其中,如下图所示:

我还为不同的屏幕大小创建了8个不同的布局文件夹,如下图所示:

如下图所示,我需要根据每个XML文件重新调整图像的大小,以便它们填满屏幕:

我使用此代码缩小图像,效果很好:

android:adjustViewBounds="true"  
    android:maxWidth="150dp" 
    android:scaleType="fitCenter"
但我不知道如何放大图像。我一直在尝试使用以下代码:

android:adjustViewBounds="true"  
    android:minWidth="150dp" 
    android:scaleType="fitCenter"
关于如何放大图片有什么想法吗?谢谢

XML:


你试过了吗

android:scaleX="1.5" // 1 is 100% size
android:scaleY="1.5"

尝试用android:scaleType=“fitXY”代替android:scaleType=“fitCenter”

编辑

使用
线性布局
布局(重量和重量总和)

根据您的
UI
调整
WeighSum
layout\u weight

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="8" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3" >

        <!-- your Match m Image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:background="#fff" >

        <!-- your play image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your Multiplayer image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your High score Image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your how to play Image -->
    </LinearLayout>
</LinearLayout>


您应为此使用新的尺寸限定符。那是最好的办法。你所做的并没有错,但是有了这么多不同种类的设备,它已经过时了。请参阅

这可用于重新调整实际图像的大小,但imageView不会随之缩放,因此图片会重叠。你知道如何使imageView与图像缩放吗?是的,我在imageView上有一个android:layout\u width=“wrap\u content”和一个android:layout\u width=“wrap\u content”用一个布局包装所有图像视图,将布局的w&h设置为与父视图匹配,并将重力设置为中心/中心水平,但是图像仍然无法放大。@Shane使用android:layout\u width=“match\u parent”和android:layout\u width=“match\u parent”“match\u parent”用图像视图填充整个屏幕。我已经用xml@Shane与使用布局权重和权重的线性布局相比,似乎有很多代码需要更改,以便为不同大小的屏幕放大图像。我正在考虑为所有分辨率制作xhdpi图像,并将其缩小到其他布局。尺寸限定符是在Android 3.2中引入的。我的应用程序需要至少支持API 8。
 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="8" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3" >

        <!-- your Match m Image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:background="#fff" >

        <!-- your play image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your Multiplayer image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your High score Image -->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <!-- your how to play Image -->
    </LinearLayout>
</LinearLayout>