实现透明渐变的Activity

如果光是透明全屏的Activity的话,直接继承内置theme即可

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

然后这里需要渐变的效果,就需要自己写drawable文件了,在drawable文件夹下创建一个xml文件

<?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中自定义一个theme

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

然后在Manifest中将这个theme运用到activity上

<activity
        ....
        android:theme="@style/Theme.ShapeBgStyle">
</activity>
原文地址:https://www.cnblogs.com/cqcmdwym/p/3282456.html