亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Android沉浸式頂部實現代碼及效果

瀏覽:18日期:2022-09-22 14:44:55

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

主頁面代碼: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(不設置狀態欄透明)、values-v19、values-v21(解決半透明遮罩問題)。

values 下 style.xml

<style name='TranslucentTheme' parent='AppTheme'> <!--在Android 4.4之前的版本上運行,直接跟隨系統主題--> </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沒有修改。

效果圖:

Android沉浸式頂部實現代碼及效果

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Android
相關文章:
主站蜘蛛池模板: 巨乳毛片| 亚洲 欧美 自拍 卡通 综合 | 国产一级片儿 | 国产对白91色拍高清精品 | 欧美一区二区三区免费不卡 | 韩国免费高清一级 | 污视频免费网站 | 在线看一区 | 色综合亚洲综合网站综合色 | 精品精品久久宅男的天堂 | 免费看国产做爰大片 | 一级特一级特色生活片 | 看真人一级毛多毛片 | 久久一区二区三区免费播放 | 精品国产午夜久久久久九九 | 欧美在线视频 一区二区 | 一区二区精品在线 | 日韩a无v码在线播放免费 | 你懂的最新网址 | 两个人看的www视频中文字幕 | 国产91视频网 | 久cao在线香蕉69影院 | 欧美特黄三级在线观看 | 国产青青草视频 | 一级视频在线观看 | h网站国产 | 欧美日韩国产58香蕉在线视频 | 久久青青草原精品影院 | 91精品欧美一区二区综合在线 | 久久99综合久久爱伊人 | 香蕉视频91 | 久久精品国产这里是免费 | 欧美伦理片在线 | 成人小视频免费 | 国产精品系列在线观看 | 91视频日本 | 国产末成年女噜噜片 | 精子网久久国产精品 | 一级毛片完整免费版 | 精品欧美一区二区vr在线观看 | 91青青|