刚开始学习安卓,在网上看到了许多怎么样建 安卓应用欢迎界面的例子。也着实的自己整理一下。
第一个方法,调用这个方法在显示一张图片,但是遇到的问题是有的时候:有的时候程序进入时候先有一片空白,然后才是这个欢迎图片
<span style="white-space:pre"> </span>super.setIntegerProperty("splashscreen", R.drawable.bg_dreams);
第二个方法,是琢磨一个同事的办法。
这是activity_main.xml的界面中一个textview的配置。起初以为 tools:context 这个属性没什么用,在查后才发现。这句代码在打包apk的时候不被打入apk。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
在AndroidManifest.xml中的activity下的android:theme属性 赋值,该activity_main下的背景都有该android:theme属性的图片渲染
<activity
android:theme="@style/MyTheme.NoTitleBar.CustomBackground" > // 这是引用的style.xml下的name为<span style="font-family: Arial, Helvetica, sans-serif;">MyTheme.NoTitleBar.CustomBackground的资源</span>
这是style.xml下配置的图片路径
<style name="MyTheme.NoTitleBar.CustomBackground" parent="@android:Theme.Black">//这个style的name为自定义的 parent不一定继承这个black。可以是light
<item name="android:windowBackground">@drawable/bg_dreams</item> //这是图片的路径,注意这个style下的itemn的那么属性为<span style="font-family: Arial, Helvetica, sans-serif;">android:windowBackground</span>