欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

主頁面代碼: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 文件,即默認的values(不設(shè)置狀態(tài)欄透明)、values-v19、values-v21(解決半透明遮罩問題)。

values 下 style.xml

<style name="TranslucentTheme" parent="AppTheme">
    <!--在Android 4.4之前的版本上運行,直接跟隨系統(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)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 淺談Android面向切面編程(AOP)

    淺談Android面向切面編程(AOP)

    這篇文章主要介紹了淺談Android面向切面編程(AOP),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • Android編程開發(fā)中的正則匹配操作示例

    Android編程開發(fā)中的正則匹配操作示例

    這篇文章主要介紹了Android編程開發(fā)中的正則匹配操作,結(jié)合具體實例形式分析了Android針對手機號、郵箱及IP的正則匹配操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下
    2017-06-06
  • popupwindow焦點問題解決方案

    popupwindow焦點問題解決方案

    在android 開發(fā)過程中,總會遇到一些問題,比如popupwindow焦點問題等等,我們該如何解決呢?需要的朋友可以了解下
    2012-11-11
  • Android獲取經(jīng)緯度計算距離介紹

    Android獲取經(jīng)緯度計算距離介紹

    Android提供LocationManager和Location,可以方便的獲得經(jīng)緯度、海拔等位置。使用LocationManager來獲得位置管理類,從而可以獲得歷史GPS信息以及位置變化的監(jiān)聽注冊;使用Location來獲得具體的位置信息
    2014-01-01
  • Android入門之Handler的使用教程詳解

    Android入門之Handler的使用教程詳解

    這篇文章主要為大家詳細介紹了Android中Handler機制的使用,文中的示例代碼講解詳細,有需要的朋友可以借鑒參考下,希望能夠?qū)Υ蠹矣兴鶐椭?/div> 2022-11-11
  • Android 換膚技術(shù)資料整理

    Android 換膚技術(shù)資料整理

    這篇文章主要介紹了 Android 換膚技術(shù)總結(jié)的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • Android Studio中Run按鈕是灰色的快速解決方法

    Android Studio中Run按鈕是灰色的快速解決方法

    這篇文章主要介紹了Android Studio中Run按鈕是灰色的快速解決方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2018-03-03
  • Android微信右滑退出功能的實現(xiàn)代碼

    Android微信右滑退出功能的實現(xiàn)代碼

    這篇文章主要介紹了Android微信右滑退出功能的實現(xiàn)代碼,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2018-01-01
  • 解析android res 運行錯誤的問題

    解析android res 運行錯誤的問題

    本篇文章是對android中res運行錯誤的問題進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • Android封裝Banner控件方法介紹

    Android封裝Banner控件方法介紹

    android-banner實現(xiàn)了一般banner循環(huán)輪播的效果,一頁只顯示一張圖片,也可以一頁顯示一張圖和相鄰兩個圖片的一部分,此項目僅僅是banner展示圖片,沒有多余的諸如指示器、頁面切換動畫等效果代碼,詳見效果圖和案例代碼
    2023-03-03

最新評論