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

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

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

研究了下這個(gè),記錄下代碼。

主頁(yè)面代碼: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>

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

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沒(méi)有修改。

效果圖:

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

相關(guān)文章

最新評(píng)論

柳河县| 天峨县| 罗平县| 陇南市| 新宁县| 日喀则市| 南陵县| 沾益县| 桂平市| 石柱| 商都县| 诸城市| 河东区| 宝应县| 叶城县| 巴林右旗| 平湖市| 重庆市| 烟台市| 伊吾县| 田阳县| 扶余县| 剑阁县| 廉江市| 丰都县| 鄂温| 卫辉市| 遂川县| 古浪县| 竹山县| 浑源县| 涿州市| 泾源县| 仁怀市| 桐柏县| 中山市| 肥西县| 保康县| 龙海市| 马山县| 阿坝县|