實現透明漸變的Activity

若是光是透明全屏的Activity的話,直接繼承內置theme便可android

<activity   
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen" </activity>

而後這裏須要漸變的效果,就須要本身寫drawable文件了,在drawable文件夾下建立一個xml文件spa

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <gradient android:angle="90"
        android:startColor="#5C000000"
        android:endColor="#F5000000"/>
</shape>

而後在values/styles.xml中自定義一個themecode

<style name="Theme.ShapeBgStyle" parent="@android:style/Theme.Translucent.NoTitleBar">
        <item name="android:windowBackground">@drawable/sharebg_shape</item>
</style>

而後在Manifest中將這個theme運用到activity上xml

<activity
        ....
        android:theme="@style/Theme.ShapeBgStyle">
</activity>
相關文章
相關標籤/搜索