最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)布局全屏

 更新時間:2021年05月08日 11:12:30   作者:xiaowen2008821  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)布局全屏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)布局全屏的具體代碼,供大家參考,具體內(nèi)容如下

前言

類似Launcher,希望占用的布局鋪滿全屏,以調(diào)整狀態(tài)欄及虛擬按鍵部分的顏色樣式。

廢話不多說,上案例:

一、效果預(yù)覽

二、案例實(shí)現(xiàn)

1.新建Android工程
2.styles樣式增加

values 目錄的styles.xml添加如下樣式:

<style name="FullTheme" parent="@style/BaseFullTheme">
</style>
<style name="BaseFullTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:colorBackgroundCacheHint">@null</item>
  <item name="android:windowShowWallpaper">true</item>
  <item name="android:windowNoTitle">true</item>
</style>

alues-v19 目錄的styles.xml添加如下樣式:

<style name="FullTheme" parent="@style/BaseFullTheme">
  <item name="android:windowTranslucentStatus">true</item>
  <item name="android:windowTranslucentNavigation">true</item>
</style>

values-v21目錄的styles.xml添加如下樣式:

<style name="FullTheme" parent="@style/BaseFullTheme">
  <item name="android:windowTranslucentStatus">false</item>
  <item name="android:windowTranslucentNavigation">false</item>
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>
  <item name="android:statusBarColor">#00000000</item>
  <item name="android:navigationBarColor">#00000000</item>
</style>

values-v29目錄的styles.xml添加如下樣式:

<style name="FullTheme" parent="@style/BaseFullTheme">
  <item name="android:colorBackgroundCacheHint">@null</item>
  <item name="android:colorEdgeEffect">#FF757575</item>
  <item name="android:windowActionBar">false</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:windowShowWallpaper">true</item>
  <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
  <item name="android:enforceStatusBarContrast">false</item>
  <item name="android:enforceNavigationBarContrast">false</item>


  <item name="android:windowTranslucentStatus">false</item>
  <item name="android:windowTranslucentNavigation">false</item>
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>
  <item name="android:statusBarColor">#00000000</item>
  <item name="android:navigationBarColor">#00000000</item>
</style>

3.布局

layout目錄建立activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/holo_blue_bright"<!-- 測試設(shè)置的顏色 -->
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">
    <Button
        android:id="@+id/test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="測試"
        >
    </Button>
</LinearLayout>

4.使用

新建MainActivity.java

package com.demo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideStatusBarNavigationBar();
        setContentView(R.layout.activity_main);
    }

   //關(guān)鍵方法
    private void hideStatusBarNavigationBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
            return;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags( WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags( WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        }
    }
}

AndroidManifest.xml聲明

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.demo">

    <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/FullTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

finish

三、填坑:fitsSystemWindows之坑

在activity_main.xml中的根布局那增加了android:fitsSystemWindows=“true”,如果不增加這個屬性,子view的布局會從最頂上開始,有興趣的可以修改了試試。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 完美解決關(guān)于禁止ViewPager預(yù)加載的相關(guān)問題

    完美解決關(guān)于禁止ViewPager預(yù)加載的相關(guān)問題

    本篇文章主要介紹了完美解決關(guān)于禁止ViewPager預(yù)加載的相關(guān)問題,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-09-09
  • Android實(shí)現(xiàn)閃屏效果

    Android實(shí)現(xiàn)閃屏效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)閃屏效果,實(shí)現(xiàn)“一閃而過”效果進(jìn)入頁面,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android自定義加載圈動畫效果

    Android自定義加載圈動畫效果

    這篇文章主要為大家詳細(xì)介紹了Android自定義加載圈動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android?進(jìn)入Activity時如何禁止彈出軟鍵盤輸入法

    Android?進(jìn)入Activity時如何禁止彈出軟鍵盤輸入法

    這篇文章主要介紹了Android?進(jìn)入Activity時如何禁止彈出軟鍵盤輸入法,文章圍繞主題展開具體內(nèi)容,需要的小伙伴可以參考一下
    2022-05-05
  • 利用Flutter實(shí)現(xiàn)背景圖片毛玻璃效果實(shí)例

    利用Flutter實(shí)現(xiàn)背景圖片毛玻璃效果實(shí)例

    Flutter沒有單獨(dú)的模糊處理容器,需要部件層層疊加實(shí)現(xiàn)模糊效果,下面這篇文章主要給大家介紹了關(guān)于利用Flutter實(shí)現(xiàn)背景圖片毛玻璃效果的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • Android監(jiān)聽ScrollView滑動距離的簡單處理

    Android監(jiān)聽ScrollView滑動距離的簡單處理

    這篇文章主要為大家詳細(xì)介紹了Android監(jiān)聽ScrollView滑動距離的簡單處理,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Android APK反編譯圖文教程

    Android APK反編譯圖文教程

    學(xué)會反編譯比較關(guān)鍵,也是我們美化必須掌握技術(shù),學(xué)會反編譯也是實(shí)現(xiàn)制作ROM的起步,ROM高手必然是反編譯高手這里有必要說一下,教程只是給你一個動手的那一個蹺板,教程不是萬能的,給了你基礎(chǔ)與啟發(fā),最重要的是我們能夠自主的進(jìn)行創(chuàng)新與思考
    2016-04-04
  • android中GridView實(shí)現(xiàn)點(diǎn)擊查看更多功能示例

    android中GridView實(shí)現(xiàn)點(diǎn)擊查看更多功能示例

    本篇文章主要介紹了android中GridView實(shí)現(xiàn)點(diǎn)擊查看更多功能示例,非常具有實(shí)用價值,需要的朋友可以參考下。
    2017-02-02
  • 利用Android中的TextView實(shí)現(xiàn)逐字顯示動畫

    利用Android中的TextView實(shí)現(xiàn)逐字顯示動畫

    在安卓程序啟動的時候,想逐字顯示一段話,每個字都有一個從透明到不透明的漸變動畫。那如何顯示這個效果,下面一起來看看。
    2016-08-08
  • Android 自定義view實(shí)現(xiàn)TopBar效果

    Android 自定義view實(shí)現(xiàn)TopBar效果

    這篇文章主要為大家詳細(xì)介紹了Android 自定義view實(shí)現(xiàn)TopBar效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-09-09

最新評論

普宁市| 承德市| 台南县| 铜川市| 青川县| 八宿县| 类乌齐县| 郯城县| 晋宁县| 民勤县| 武川县| 宁晋县| 子洲县| 宝坻区| 民乐县| 晋宁县| 新干县| 丽水市| 克拉玛依市| 馆陶县| 兴仁县| 宁阳县| 肥城市| 黄冈市| 渑池县| 安阳市| 句容市| 台东县| 万载县| 嘉峪关市| 合阳县| 庐江县| 榆中县| 昆山市| 通海县| 遂昌县| 洞口县| 夏河县| 平定县| 石门县| 昆明市|