日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

android fitsSystemWindows的使用

發(fā)布時間:2024/4/15 windows 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android fitsSystemWindows的使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

今天,簡單講講android 

fitsSystemWindows的使用。


Android使用fitsSystemWindows屬性實現(xiàn)--狀態(tài)欄【status_bar】各版本適配方案


fitSystemWindows屬性:

????官方描述:

????????Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

????簡單描述:

?????這個一個boolean值的內(nèi)部屬性,讓view可以根據(jù)系統(tǒng)窗口(如status bar)來調(diào)整自己的布局,如果值為true,就會調(diào)整view的paingding屬性來給system windows留出空間....

實際效果:

?????當(dāng)status bar為透明或半透明時(4.4以上),系統(tǒng)會設(shè)置view的paddingTop值為一個適合的值(status bar的高度)讓view的內(nèi)容不被上拉到狀態(tài)欄,當(dāng)在不占據(jù)status bar的情況下(4.4以下)會設(shè)置paddingTop值為0(因為沒有占據(jù)status bar所以不用留出空間)。


  • 1.fitsSystemWindow 默認(rèn)是true,就是組件都在屏幕內(nèi),但是不包括statusBar。設(shè)置成false后,整個屏幕都可以放置組件,沒有statusBar和window之分。

  • 2.android:fitsSystemWindows=“true”在布局中占有最高權(quán)限,如果明確設(shè)置為true,style設(shè)置fits為false是無效的;同理,只在布局中設(shè)置fits而沒有設(shè)置style也是無效的。

平時使用中只需要設(shè)置style即可。效果就是整個圖片鋪滿手機界面。


<style name="NoStatusStyle" parent="AppTheme"> <item name="android:windowTranslucentStatus">true</item> <!--狀態(tài)欄為透明,如果設(shè)置為false,則沒有黑色條蓋住,見下圖對比--> <item name="android:windowTranslucentNavigation">true</item> <!--導(dǎo)航欄為透明--> <item name="android:statusBarColor">@android:color/transparent</item> </style>



(注:在布局中都是android:fitsSystemWindows="false")


3.有時候會出現(xiàn)statusbar把界面蓋住的情況,一般都是fits設(shè)置的有問題,或是在布局(android:fitsSystemWindows="false"),或是在style中fits設(shè)置為了false(<item name="android:fitsSystemWindows">false</item>),但是statusbar沒有設(shè)置為透明,造成了界面被遮蓋的現(xiàn)象。解決辦法就是上面的代碼塊中的代碼。(要明白自己的意圖再去修改)


android fitsSystemWindows的使用就講完了。


就這么簡單。

總結(jié)

以上是生活随笔為你收集整理的android fitsSystemWindows的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。