我正在創建一個簡單的測驗應用程序「目標SDK API 16(4.1果凍豆)」屏幕3.7(480x800 hdpi)。如何自動調整大小,兼容,調整所有Android設備的屏幕大小
這個應用程序在3.7(480x800)上看起來不錯,但是當我在另一個屏幕設備上運行它時,如:2.7(240x320),7.0(1024x600),10.1(1280x800),屏幕分辨率會變差或看起來很糟糕。
更好地瞭解見截圖:
2.7(240×320)
http://postimg.org/image/m3sob88mp/
3.7(480×800)
http://postimg.org/image/wf513w0c1/
7.0(1024×600)
http://postimg.org/image/fc298djn5/
10.1(1280×800)
http://postimg.org/image/isk5gon7p/
我想這兼容/尋找完美與所有的屏幕尺寸就像它會在3.7(480×800 )
如何自動調整大小,兼容,調整所有android設備的屏幕大小,使其看起來十分完美ry屏幕分辨率。
或者我將不得不創建不同的應用或不同的屏幕尺寸。
什麼,我試圖讓屏幕兼容是: 添加這些行 「的AndroidManifest.xml」
<supports-screens>
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
</supports-screens>
AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.usd.quiztest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<supports-screens>
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"
</supports-screens>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.usd.quiztest.Logo"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.usd.quiztest.First"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Q1"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Q2"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Q3"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Q4"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Q5"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.FinalPage"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.usd.quiztest.Score"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
first_screen.xml(這是屏幕截圖所示)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:contentDescription="ql"
android:gravity="center"
android:src="@drawable/ql" />
<Button
android:id="@+id/start_button"
android:layout_width="254dp"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="Start Quiz Test"
android:textColor="#000000" />
</RelativeLayout>
您需要爲所有設備使用不同的drawable。像hdpi,mdpi,xhdpi等。 這將根據設備偏好選擇圖像。 –
供您參考:http://developer.android.com/guide/practices/screens_support.html –
向我們展示您的佈局。 XML,我懷疑有一些錯誤。 – Leandros