午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

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

瀏覽:111日期: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
相關文章:
主站蜘蛛池模板: 亚洲成人动漫在线观看 | 精品免费看 | 成人久久久久久久 | 午夜av毛片| 久久婷婷六月 | 国产视频1区2区 | 免费在线一区二区三区 | 九九热在线视频免费观看 | 老汉av在线 | 少妇操bb| 神马一区二区三区 | 操中国女人的逼 | 国模吧一区二区 | wwwav视频| 欧美 中文字幕 | 日本www黄| 一区二区高清在线 | 欧美又大粗又爽又黄大片视频 | 日韩成人在线播放 | 日韩av在线看免费观看 | 国产精品视频看看 | 丁香花五月婷婷 | 日韩久久一区二区三区 | 精品视频一区二区三区在线观看 | 在线观看av的网站 | 99er视频| 在线久久| 91精品国产欧美一区二区成人 | 在线观看视频中文字幕 | 国产超级av | 欧美成人精品欧美一级乱黄 | 精品国产第一页 | 青青草综合网 | 岛国成人在线 | 九九九久久久久 | 国产午夜影院 | 超碰人人人人人人 | 99久久99久久精品国产片果冻 | 黄色免费看 | 在线看日韩 | 亚洲高清中文字幕 |