Java怎么实现渐变色沉浸式状态栏-创新互联

这篇文章主要介绍“Java怎么实现渐变色沉浸式状态栏”,在日常操作中,相信很多人在Java怎么实现渐变色沉浸式状态栏问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Java怎么实现渐变色沉浸式状态栏”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、虚拟主机、营销软件、网站建设、江阴网站维护、网站推广。
在AndroidManifest.xml中的activity中使用自定义主题
<activity android:name=".dailyAccompany.view.activity.AlarmListActivity"
    android:theme="@style/TranslucentStatusTheme"
    android:screenOrientation="portrait">
</activity>

然后在style.xml中去定义该主题

values的styles.xml

<!--透明状态栏-->
<style name="TranslucentStatusTheme" parent="Theme.AppCompat.Light.NoActionBar">
 
</style>

values-v19的styles.xml

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

values-v21的styles.xml

<style name="TranslucentStatusTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowTranslucentStatus">false</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

在布局文件中的第一个控件设置为渐变

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/alarm_shade_bg"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">
 
    <ImageView
        android:id="@+id/alarm_top"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:background="@drawable/title_shade_bule"/>

   省略中间布局。。。。。。。。。。。。。。。。。。

</android.support.constraint.ConstraintLayout>

然后去定义渐变布局title_shade_bule

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="180"
        android:centerColor="#2798f0"
        android:endColor="#6043ce"
        android:startColor="#6043ce"
        android:type="linear" />
</shape>

就可以实现了

注:如果顶部是使用Toolbar,需要在Toolbar中加上

android:fitsSystemWindows="true"

到此,关于“Java怎么实现渐变色沉浸式状态栏”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联-成都网站建设公司网站,小编会继续努力为大家带来更多实用的文章!

当前标题:Java怎么实现渐变色沉浸式状态栏-创新互联
当前URL:https://www.cdcxhl.com/article6/csieig.html

成都网站建设公司_创新互联,为您提供微信公众号网站建设外贸网站建设域名注册营销型网站建设软件开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

营销型网站建设