แถบสถานะโปร่งแสงของ Android แต่แถบนำทางไม่โปร่งแสง (ถ้ามี)

ฉันกำลังพยายามสร้างหน้าจอสแปลชสำหรับแอปพลิเคชัน Android ด้วยบทความนี้: หน้าจอสแปลชอย่างถูกวิธี ดังที่บทความกล่าวไว้ ฉันสร้าง LayerDrawable ด้วยสองชั้น: บิตแมปพื้นหลังและโลโก้ (รวมถึงบิตแมปด้วย) โลโก้จะต้องอยู่ที่ด้านล่างของหน้าจอโดยมีการเยื้อง 32dp เป็นต้น ที่นี่สิ่งที่วาดได้ของฉัน:

<item
    android:drawable="@drawable/splash_image" />

<item
    android:id="@+id/logo"
    android:bottom="@dimen/margin_splash">

    <bitmap
        android:gravity="bottom|center"
        android:src="@drawable/logo_green" />
</item>

I pointed this drawable as android:windowBackground param in my splash activity theme. I also want to have transparent status bar when splash screen is shown on devices where this feature is supported (API >=19), so I created two resource files for different android versions and in values-v19\styles.xml I pointed flag android:windowTranslucentStatus as true. Here my values/styles.xml and values-v19/styles.xml:

ค่า/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/bg_splash</item>
    </style>
</resources>

และ
values-v19/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/bg_splash</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

แต่ในอุปกรณ์ Android บางรุ่นที่มี Soft NavigationBar โลโก้ของฉันซ้อนทับกัน โลโก้ซ้อนทับกันโดย NavigationBar
ฉันพยายามชี้ธง android:windowTranslucentNavigation เป็นเท็จแต่ก็ไม่สำเร็จ

มีวิธีใดที่จะทำให้ Android Soft NavigationBar โปร่งใสพร้อมกับแถบสถานะโปร่งใสหรือฉันต้องตรวจสอบความพร้อมใช้งานของ Soft NavigationBar ในวิธีการ onCreate ของกิจกรรมสแปลชของฉันและอัปเดต LayerDrawable ของฉันโดยเพิ่มการเยื้องด้านล่างสำหรับโลโก้ที่ความสูงของ NavigationBar

ขอบคุณ.


person ibogolyubskiy    schedule 26.02.2017    source แหล่งที่มา


คำตอบ (2)


คุณลองสิ่งนี้แล้วหรือยัง?

<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">false</item>

นอกจากนี้คุณยังสามารถเติมด้านล่างเล็กน้อยให้กับรายการบิตแมปของคุณในเลเยอร์ที่วาดได้

person albeee    schedule 26.02.2017

ฉันพบปัญหาเดียวกันและแก้ไขปัญหานี้โดยการตั้งค่าคุณลักษณะต่อไปนี้

<item name="android:windowDrawsSystemBarBackgrounds">false</item>

แอ็ตทริบิวต์นี้ถูกตั้งค่าเป็นไดเร็กทอรี Values-v21

person angelo yan    schedule 18.04.2017