0

I used <item name="android:windowTranslucentStatus">true</item> to make my navigation drawer move behind the status bar. But now when I create a new activity, it makes the whole activity to move behind status bar too (like the textview behind the status bar in the image:

enter image description here

Also I want the status bar color to match the app theme in the new activity.

New activity's java file:

public class AddStudent extends AppCompatActivity {

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

New activity's xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.gupta.aayush.tuitionmanager.AddStudent"
android:orientation="vertical">

<TextView
    android:id="@+id/textView4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="TextView" />
</LinearLayout>
Aayush Gupta
  • 55
  • 11
  • you should check the xml layout file for the new activity and look for placement of the navigation drawer and where it is being placed at. The new activity's java file should also be applying the navigation drawer somewhere in the view. As for the status bar, I do not believe you can change the color. You should make the app fullscreen, that way the status bar is hidden and you don't have to worry about its color – Eric Reyna Mar 14 '17 at 18:28
  • @EricReyna I have not done anything on the Java or xml file yet. There's only one line code i.e setContentView(R.layout.activity_add_student); (add student is the new activity). As for the xml file, I have only added the text view (I am adding that to the post too). Help please! – Aayush Gupta Mar 14 '17 at 18:39

1 Answers1

2

Add android:fitsSystemWindows="true" to your root LinearLayout.

See this for a detailed explanation.

Community
  • 1
  • 1
azizbekian
  • 60,783
  • 13
  • 169
  • 249