android支持多屏幕和多个drawable

时间:2014-01-06 15:33:03

标签: android drawable

我已经制作了三个同名的文件。

96 * 96 = xhigh:

enter image description here

72 * 72 =高:

i.stack.imgur.com/SCmLV.png

48 * 48 =中等:

i.stack.imgur.com/oxX0d.png

当我创建一个480 * 854(hdpi)的AVD时,选择了第三个图像。 为什么?

i.stack.imgur.com/7kIlv.jpg

i.stack.imgur.com/1qZwA.jpg

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ex31"
android:versionCode="1"
android:versionName="1.0" >

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />

 <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.ex31.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

布局:

<RelativeLayout 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" >

<ImageView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/one"
    />

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

您的模拟器似乎未设置为正确的DPI。打开Android虚拟设备管理器并检查hw.lcd.density是否(大致)240.请记住,DPI为160是基线1x或mdpi。

看起来应该是这样的:

Emulator with hdpi

启动模拟器时,您还应该看到密度箱:

Launching hdpi emulator