AppCompatActivity透明化处理

本文解决了

有关AppCompatActivity透明化处理的失败探索历程

http://blog.csdn.net/lq2007lq/article/details/52606797

当Activity继承于AppCompatActivity时,只能使用Theme.AppCompat下的主题。而这些主题并没有Translucent.提示错误: 
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.


可以采用自定义主题来弥补AppCompat中无透明主题,方式如下:

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/theme</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:background">@color/translate</item>
    </style>
    <!--全屏加透明-->
    <style name="TranslucentFullScreenTheme" parent="FullScreenTheme">
        <item name="android:windowBackground">@color/translate</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>
    <!--全屏-->
    <style name="FullScreenTheme" parent="AppTheme">
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
    <!--透明,有任务栏电量时间等-->
    <style name="NoTitleTranslucentTheme" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@color/translate</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值