<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kotlin on fairy-domain</title><link>/tags/kotlin/</link><description>Recent content in Kotlin on fairy-domain</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>© 2023 Powered by fairy-domain</copyright><lastBuildDate>Thu, 04 Feb 2021 09:22:07 +0800</lastBuildDate><atom:link href="/tags/kotlin/index.xml" rel="self" type="application/rss+xml"/><item><title>Android Fullscreen</title><link>/posts/android-fullscreen/</link><pubDate>Thu, 04 Feb 2021 09:22:07 +0800</pubDate><guid>/posts/android-fullscreen/</guid><description>沉浸状态栏应用Android应用中很常见,作为新手自己找了很多资料，并无比较完美的结果，也问了身边做Android的大佬，给出的答案也理想，自己各种bing，最终终于找个了满意的结果。 具体实现代码（Kotlin）如下：
if (Build.VERSION.SDK_INT &amp;gt;= 30) { window.setDecorFitsSystemWindows(false) } else { @Suppress(&amp;#34;DEPRECATION&amp;#34;) window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE) } 全屏后 Toolbar 最好使用 AppBarLayout 包裹，设置 AppBarLayout 背景颜色即可完成顶部的 Toolbar 大概如下：
&amp;lt;com.google.android.material.appbar.AppBarLayout android:layout_width=&amp;#34;match_parent&amp;#34; android:layout_height=&amp;#34;wrap_content&amp;#34; android:fitsSystemWindows=&amp;#34;true&amp;#34;&amp;gt; &amp;lt;androidx.appcompat.widget.Toolbar android:layout_width=&amp;#34;match_parent&amp;#34; android:layout_height=&amp;#34;wrap_content&amp;#34; android:minHeight=&amp;#34;?attr/actionBarSize&amp;#34; android:overScrollMode=&amp;#34;always&amp;#34; app:layout_scrollFlags=&amp;#34;snap|exitUntilCollapsed&amp;#34; app:title=&amp;#34;@string/nav_giftware_title&amp;#34; app:titleTextColor=&amp;#34;@color/white&amp;#34; /&amp;gt; &amp;lt;/com.google.android.material.appbar.AppBarLayout&amp;gt;</description><content>&lt;p>沉浸状态栏应用Android应用中很常见,作为新手自己找了很多资料，并无比较完美的结果，也问了身边做Android的大佬，给出的答案也理想，自己各种bing，最终终于找个了满意的结果。
具体实现代码（Kotlin）如下：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">if&lt;/span> (&lt;span style="color:#a6e22e">Build&lt;/span>.&lt;span style="color:#a6e22e">VERSION&lt;/span>.SDK_INT &lt;span style="color:#f92672">&amp;gt;=&lt;/span> &lt;span style="color:#ae81ff">30&lt;/span>) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> window.setDecorFitsSystemWindows(&lt;span style="color:#66d9ef">false&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>} &lt;span style="color:#66d9ef">else&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">@Suppress&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;DEPRECATION&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> window.decorView.systemUiVisibility = (&lt;span style="color:#a6e22e">View&lt;/span>.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> or &lt;span style="color:#a6e22e">View&lt;/span>.SYSTEM_UI_FLAG_LAYOUT_STABLE)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>全屏后 Toolbar 最好使用 AppBarLayout 包裹，设置 AppBarLayout 背景颜色即可完成顶部的 Toolbar 大概如下：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-xml" data-lang="xml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">&amp;lt;com.google.android.material.appbar.AppBarLayout&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:layout_width=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:layout_height=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:fitsSystemWindows=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#f92672">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">&amp;lt;androidx.appcompat.widget.Toolbar&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:layout_width=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:layout_height=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:minHeight=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;?attr/actionBarSize&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">android:overScrollMode=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;always&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">app:layout_scrollFlags=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;snap|exitUntilCollapsed&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">app:title=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;@string/nav_giftware_title&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">app:titleTextColor=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;@color/white&amp;#34;&lt;/span> &lt;span style="color:#f92672">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">&amp;lt;/com.google.android.material.appbar.AppBarLayout&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></content></item></channel></rss>