android沉浸式状态栏与text文字设置多种颜色

14 篇文章 0 订阅
4 篇文章 0 订阅

沉浸式状态栏


只支持4.4以上版本,4.4效果为渐变透明色,5.0支持全透明状态栏

1.首先配置沉浸式(透明状态栏)样式主题
values-v19
styles.xml

    <style name="TranslucentTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>

values-v21
styles.xml

    <style name="TranslucentTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowTranslucentStatus">false</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色-->
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

2.清单文件对应的activity引用刚才创建的主题

        <activity
            android:name=".module.login.LoginActivity"
            android:theme="@style/TranslucentTheme" />
        <activity

3.对应activity布局文件的根布局中加入android:fitsSystemWindows=”true”
或代码实现

        ViewGroup contentFrameLayout = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT);
        View parentView = contentFrameLayout.getChildAt(0);
        parentView.setFitsSystemWindows(true);

text文字设置多种颜色

1.添加字符串配置
values
strings.xml

<string name="register_read_service"><Data><![CDATA[我已仔细阅读并同意《<font color="#52affc">服务协议</font>》]]></Data></string>

2.代码初始化值的时候使用html工具格式化成对应的html效果

mRegisterRead.setText(Html.fromHtml(getResources().getString(R.string.register_read_service)));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值