I'm trying to get the background of my splash screen to be opaque/transparent. I made a colors.xml in values:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="translucent_black">#00000000</color>
</resources>
Then I have my splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@开发者_JAVA百科color/translucent_black">
<ImageView android:layout_width="wrap_content" android:id="@+id/imageView1"
android:src="@drawable/splash" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerInParent="true"></ImageView>
</RelativeLayout>
I feel like I should have something in the manifest, but I keep getting errors putting activitys in. Also if you are really feeling frisky, I can figure out how to make the title bar go away either. Thanks again.
Simple Method
Specify the activity to use the translucent theme (in manifest.xml):
<activity ...
android:theme="@android:style/Theme.Translucent"
.../>
Advanced Method
If you want more customisability you can create your own theme extending the Translucent theme (manifest.xml):
<activity ...
android:theme="@android:style/Theme.MyTranslucentTheme"
.../>
and in styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTranslucentTheme" parent="android:Theme.Translucent">
<item name="android:windowBackground">@color/transparent_black</item>
</style>
<color name="transparent_black">#DA000000</color>
</resources>
If you use
<
activity
...
android:theme="@android:style/Theme.Translucent"
....../>
you have to extend Activity
instead of AppCompatActivity
in Activity.class
inheritance.
精彩评论