久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:34日期: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(不設(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沒有修改。

效果圖:

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

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

標簽: Android
相關(guān)文章:
主站蜘蛛池模板: 亚洲一区二区 | 综合久久久久久久 | 日本久久久久久久久 | 欧美日韩一区二区三区在线观看 | 国产精品久久嫩一区二区 免费 | 午夜精品影院 | 我要看黄色一级大片 | 欧美午夜一区二区福利视频 | 夜夜操com| 亚洲成人av在线 | 免费成人激情视频 | 国产精品久久a | 亚洲国产一区二区在线 | 国产精品视频一二三区 | 午夜精品久久久久久久白皮肤 | 亚洲午夜电影 | 成人aaa| 精品日韩 | 日韩国产精品一区二区三区 | 嫩草视频在线观看免费 | 国产一区二区三区视频 | 亚洲国产精品成人久久久 | 成人一区二区三区在线 | 欧美一区二区日韩 | 中文字幕国产区 | 欧美一级大片 | 亚洲三区在线观看 | 91日韩欧美 | 成人精品久久 | www国产免费 | 四影虎影www4hu23cmo | 一级片在线观看 | 午夜不卡福利视频 | 一区二区日韩 | 性色视频在线观看 | 成人av片在线观看 | 91.xxx.高清在线 | 日本免费一区二区三区 | 亚洲三区在线观看 | 美女扒开内裤让男人桶 | 亚洲三级视频 |