要將其調節到屏幕上,你只需要相應地調整其大小,然後創建這樣的可繪製文件爲每個畫面大小(本例將顯示梯度的背景與在中心的圖像)
<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>
我希望這可以幫助你
注意:如果您將創建的樣式設置爲整個應用程序的主題,則會在奇怪的位置顯示您的繪圖,如在軟鍵盤的背景中
您是否創建了佈局fo r大,xlarge屏幕? – Stanojkovic