最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android沉浸式頂部實(shí)現(xiàn)代碼及效果

 更新時間:2020年09月22日 15:11:05   作者:手撕高達(dá)的村長  
這篇文章主要介紹了Android沉浸式頂部實(shí)現(xiàn)代碼及效果,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

研究了下這個,記錄下代碼。

主頁面代碼:activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"

  tools:context=".MainActivity">

  <TextView
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:text="Hello World!"

    android:gravity="center"
    android:background="@color/colorAccent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
  <!-- android:fitsSystemWindows="true" android:clipToPadding="true"-->
</android.support.constraint.ConstraintLayout>

添加三個文件:三份 style 文件,即默認(rèn)的values(不設(shè)置狀態(tài)欄透明)、values-v19、values-v21(解決半透明遮罩問題)。

values 下 style.xml

<style name="TranslucentTheme" parent="AppTheme">
    <!--在Android 4.4之前的版本上運(yùn)行,直接跟隨系統(tǒng)主題-->

  </style>

values-v19 下 style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="TranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
  </style>

</resources>

values-v21 下 style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="TranslucentTheme" 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>

</resources>

這里需要在:AndroidMainfest.xml 里添加樣式。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="controller.hzl.com.dingbu2">

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
      android:theme="@style/TranslucentTheme"
      >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>

</manifest>

主Acitivity沒有修改。

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

永年县| 多伦县| 山西省| 尚义县| 安阳市| 自治县| 泽州县| 洪泽县| 马鞍山市| 元谋县| 庆城县| 麦盖提县| 兴海县| 宝鸡市| 大邑县| 尉犁县| 自贡市| 聂拉木县| 加查县| 通河县| 和顺县| 舟曲县| 临沂市| 龙胜| 霍山县| 房产| 柘城县| 永年县| 武强县| 梁山县| 道真| 八宿县| 读书| 磐安县| 巴林右旗| 湘潭县| 那坡县| 宜良县| 南安市| 黎城县| 西贡区|