简体   繁体   中英

PNG image not scaling to full screen size

I have a splash screen on my android app, which is populated by a png image. However the png image is not populating the full screen, there are spaces showing on the sides.

I am viewing this on and AVD.

Here is what I see: 我的SPLASHSCREEN的视图

Here is my XML code:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

 <ImageView
 android:src="@drawable/splash"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"></ImageView>  

</LinearLayout>

Here is an extract of my Android Manifest code:

<uses-sdk
    android:minSdkVersion="5"
    android:targetSdkVersion="17" />

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


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" >
            <activity
        android:name="com.shaadcorp.wazaifapp.MainMenu"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="ButtonMenu"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.shaadcorp.wazaifapp.CLEARSCREEN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>   
    <activity
        android:name="wazeefa"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.shaadcorp.wazaifapp.WAZEEFA" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="durood"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.shaadcorp.wazaifapp.DUROOD" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

</application>

</manifest>

Please can any one help? I have tried to increse the dimesions of the png itself but this makes no difference.

You need to add the android:scaleType attribute to the ImageView . Probably centerCrop is what you want.

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="centerCrop"
    android:src="@drawable/splash" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM