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

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

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

瀏覽:41日期: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
相關文章:
主站蜘蛛池模板: 日本xxxx韩国护士 | 日本亚洲国产精品久久 | xx中文字幕乱偷avxx | 欧美高清一区二区三区欧美 | 麻豆国产精品入口免费观看 | 欧美视频在线观看一区二区 | 亚洲激情视频 | 丁香婷婷综合网 | 最新国产精品精品视频 | 高清视频一区 | 黄色免费网站在线播放 | 成人做爰全过程免费看网站 | 国产精品欧美日韩一区二区 | 国产日韩欧美不卡www | 深夜偷偷看视频在线观看 | 久久精品韩国日本国产 | 青青影院一区二区免费视频 | 国产一级视频在线观看 | 风间由美理伦片在线观看 | 欧美综合图片一区二区三区 | www亚洲成人 | 国产精品美女自在线观看免费 | 中文字幕成人在线 | 国产在线视频精品视频免费看 | 欧美精品v日韩精品v国产精品 | 亚洲国产精品综合久久一线 | 成年女人天堂香蕉网视频 | 日本无卡αv免费视频 | 中日韩欧美在线观看 | 国产免费高清mv视频在线观看 | 久久精品女人毛片国产 | 99国产成+人+综合+亚洲 欧美 | 打床炮视频在线观看免费 | 亚洲国产欧美日韩一区二区 | 毛片大全免费 | 久久久国产99久久国产久 | 伊人久久精品 | 精品亚洲永久免费精品 | 久久99青青久久99久久 | 乱色专区| 黄色三级影院 |