欢迎光临成都祈钰瑶科技有限公司网站!祝您生活愉快!
热线电话: 18982081108
✕

成都服务器托管,成都GPU服务器租用,成都高防BGP宽带租用,成都机柜租用托管

Java怎么实现渐变色沉浸式状态栏

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

成都创新互联成立以来不断整合自身及行业资源、不断突破观念以使企业策略得到完善和成熟,建立了一套“以技术为基点,以客户需求中心、市场为导向”的快速反应体系。对公司的主营项目,如中高端企业网站企划 / 设计、行业 / 企业门户设计推广、行业门户平台运营、App定制开发、手机网站制作设计、微信网站制作、软件开发、四川电信机房托管等实行标准化操作,让客户可以直观的预知到从成都创新互联可以获得的服务效果。

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