2016-04-03 181 views
0

我遇到了Android初始屏幕的問題。Android初始屏幕縮水

我做啓動畫面像這些

/platform/android/res/drawable-hdpi/background.9.png 
/platform/android/res/drawable-mdpi/background.9.png 
/platform/android/res/drawable-xhdpi/background.9.png 
/platform/android/res/drawable-xxhpi/background.9.png 
/platform/android/res/drawable-xxxhdpi/background.9.png 

這些由ticon自動進行。

並已確認這些看起來OK(正確的background.9下面)。

但是,當我打開應用程序(在Nexus7 2013上),splashscreen看起來小得多。

我的意思是background.9.png居中,圖像周圍有白色空白。

我怎樣才能把它調整到屏幕???

+0

您是否創建了佈局fo r大,xlarge屏幕? – Stanojkovic

回答

0

要將其調節到屏幕上,你只需要相應地調整其大小,然後創建這樣的可繪製文件爲每個畫面大小(本例將顯示梯度的背景與在中心的圖像)

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 


<item> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient 
     android:startColor="#2b3143" 
     android:centerColor="#37465e" 
     android:endColor="#55647c" 
     android:angle="135"/> 
</shape> 
</item> 

<item> 
    <bitmap 
     android:gravity="center" 
     android:src="@drawable/myCuteLogo"/> 
</item> 

然後創建一個樣式,設置屬性android:windowBackground與您創建的繪製:

<style name="SplashScreenStyle" parent="myAppTheme"> 
    <item name="android:windowBackground">@drawable/splash_screen</item> 
</style> 

然後創建一個SplashActiv兩者均會顯示啓動畫面:

public class SplashScreen extends AppCompatActivity { 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    Intent intent = new Intent(this, Activity_a_Main.class); 
    startActivity(intent); 
    finish(); 
}} 

最後在你的清單設置SplashActivity爲Lancher活動,並設置其主題爲您創建的風格:

<activity android:name=".Activities.SplashScreen" 
     android:theme="@style/SplashScreenStyle"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

我希望這可以幫助你

注意:如果您將創建的樣式設置爲整個應用程序的主題,則會在奇怪的位置顯示您的繪圖,如在軟鍵盤的背景中

+0

謝謝你的回答,我正在努力嘗試,現在正在努力。 – whitebear

+0

你可以隨時問 –