2016-04-28 4 views
6

Konnte mir jemand mit folgendem Bild helfen. Da muss ich Gradienten auf die Statusleiste anwenden. Ich weiß, dass sie nur eine einzige Farbe in der Statusleiste haben, indem sie colorPimaryDark verwenden.Wie wendet man den Verlauf auf die Statusleiste in Android an?

Wie Sie in Bild sehen können, zeigt es denselben Gradienten in der Statusleiste wie im Verifizierungslayout.

Dank

+1

[http://meta.stackoverflow.com/questions/266384/is-it-ok-to-downvote-questions-asking-about-how-to-achieve-something-without-ha ] (http://meta.stackoverflow.com/questions/266384/is-it-ok-to-downvote-questions-asking-about-how-to-achieve-irgendwas-ohne-ha) –

+1

setzen Statusleiste transparent und Machen Sie die Symbolleiste groß und setzen Sie den Farbverlauf. –

+0

Thema? @ ZahidulIslam –

Antwort

18

Ihre oncreate wie dieses

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 
     Window w = getWindow(); 
     w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); 
     w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 
    } 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
} 

Das Layout-Datei so sein sollte sein sollte.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:background="#fff" 
    tools:context="sslwireless.com.testfullscreen.MainActivity"> 

    <!--RePresent Toolbar--> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:background="@drawable/gradient" 
     android:layout_width="match_parent" 
     android:layout_height="100dp"> 

     <ImageView 
      android:layout_gravity="center_vertical" 
      android:src="@drawable/ic_arrow_back_white_24dp" 
      android:layout_marginLeft="10dp" 
      android:layout_width="35dp" 
      android:layout_height="35dp" /> 

     <TextView 
      android:layout_gravity="center_vertical" 
      android:textSize="25sp" 
      android:gravity="center_horizontal" 
      android:textColor="#fff" 
      android:text="Test Title" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 


</RelativeLayout> 

Und die Verlaufsdatei sieht so aus.

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient android:angle="135" android:startColor="#f56f2c" android:endColor="#fa9f46"/> 
</shape> 

Das UI wird so aussehen.

enter image description here

+0

danke für die nette Antwort und Widmung. Gibt es in irgendeiner Weise nur die Statusleiste, die sowohl die Statusleiste als auch die Navigationsschaltfläche auf der Unterseite transparent und nicht transparent macht. –

+0

android: windowSoftInputMode = "adjustPan" funktioniert nicht :(Die Soft-Tastatur deckt jetzt die EditTexts ab. – Khan

Verwandte Themen