10

Google Now와 비슷한 상태 표시 줄과 탐색 모음 그라데이션을 만들려고합니다.상태 표시 줄 및 탐색 모음의 Google Now 그라데이션/그림자

이미지 참조 : 사각형 영역

<item name="android:windowTranslucentNavigation">true</item> 
    <item name="android:windowTranslucentStatus">true</item> 

내가 아래 행동을

이미지 참조를 얻을 안드로이드 산들 바람에 아래의 옵션을 시도 후

enter image description here

아래로 표시 :

enter image description here

아무에게도이 두 가지에 그라데이션을 얻는 방법을 제안 할 수 있습니까?
그라디언트입니까, 아니면 그림자입니까?

+0

는, 당신이 –

+0

당신이 '의 minSdkVersion'또는 'targetSdkVersion을 언급하는 오래된 OS 옵션을 추가해야 것을 '?? .... 나는 안드로이드 6.0 장치에서 테스트 중이 야, 구글 스크린 샷은 또한 같은 장치에서 가져온 것입니다 ... 나는 21로, 그리고 targetSdkVersion 23로 minSdkVersion 내 샘플 애플 리케이션에 언급했습니다 –

답변

4

scrim으로 사용되는 그래디언트입니다. 이 효과를 얻으려면 먼저 상태 및 탐색 막대의 반투명 언더 레이를 제거해야합니다. Another answer 하위 플랫폼 장치에서이 작업을 수행하는 방법에 대해 자세히 설명합니다. 하지만 안드로이드 롤리팝 이상에, 당신은 단순히 두 가지 스타일을 설정하여이 작업을 수행 할 수 있습니다 투명 속성을 : 당신이 그런

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 

    <gradient android:type="linear" 
     android:angle="270" 
     android:centerY="0.3" 
     android:startColor="#66000000" 
     android:centerColor="#33000000" 
     android:endColor="#00000000"/> 

</shape> 

:

다음
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 
    <style name="Theme" parent="android:Theme.Material.Wallpaper.NoTitleBar"> 
     <item name="android:statusBarColor">@android:color/transparent</item> 
     <item name="android:navigationBarColor">@android:color/transparent</item> 
     <item name="android:windowTranslucentStatus">true</item> 
     <item name="android:windowTranslucentNavigation">true</item> 
    </style> 
</resources> 

에서, 스크림을 추가, 당신은 드로어 블 모양을 사용할 수 있습니다 또한 일의 바닥에 동일한 기울기를 사용하도록 android:rotation="180" 속성을 설정할 수 있습니다

<View 
    android:layout_width="match_parent" 
    android:layout_height="72dp" 
    android:background="@drawable/scrim"/> 

: 당신의 레이아웃에 View의 배경으로 이것을 설정할 수 있습니다 전자 스크린.

+0

만약 내가 올바르게 통지, 나는 그것의 스크램블을 가지고있는 앱이 아니라 지금 홈 스크린 (즉 상태 표시 줄 자체가 스크림을 가지고 있음)을 볼 수있었습니다. 우리는 상태 표시 줄의 안드로이드 소스 코드, 스크림이 어떻게 적용되는지 확인할 수 있습니다. –

+0

@Jitendar 상태 표시 줄에 직접 적용되지 않는다고 생각합니다 (완전히 배제하지는 않지만). 나는 [Google Now 실행기] (https://play.google.com/store/apps/details?id=com.google.android.launcher & hl = en)은 오픈 소스가 아니며 홈 화면에 내용 스크림을 적용합니다. – Bryan

1

먼저 완전히 투명한 동작 상태 표시 줄 만들기 위해 스타일을 추가 :

<!-- Base application theme. --> 
<style name="TransparentTheme" parent="android:Theme.Holo.Light"> 
<!-- Customize your theme here. --> 
<item name="android:windowBackground">@null</item> 
<item name="android:actionBarStyle">@style/ActionBarStyle.Transparent</item> 
<item name="android:windowActionBarOverlay">true</item> 
</style> 

<style name="ActionBarStyle.Transparent" parent="android:Widget.ActionBar"> 
<item name="android:background">@null</item> 
<item name="android:displayOptions">showHome|showTitle</item> 
<item name="android:titleTextStyle">@style/ActionBarStyle.Transparent.TitleTextStyle</item> 
</style> 

<style name="ActionBarStyle.Transparent.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> 
<item name="android:textColor">@android:color/white</item> 
</style> 

하고 드로어 블 파일을 생성하고이 코드를 추가에 스크림을 추가 :

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="#88000000" /> 
<gradient 
    android:angle="90" 
    android:centerColor="#66000000" 
    android:centerY="0.3" 
    android:endColor="#00000000" 
    android:startColor="#CC000000" 
    android:type="linear" /> 
</shape> 

및 배경으로이 추가 당신의 주제에서;

이 링크를 체크 아웃 할 수
+0

예전처럼 작동하지 않았지만 답변에서 좋은 힌트를 얻습니다. – Dhruv