Big_Energy
Big_Energy

Reputation: 43

Toolbar moved up

Toolbar moved up

https://i.sstatic.net/QCXYs.png

How to make a normal?

And how to make transparent toolbar ? I use drawer by mike penz and tabs activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_activity_DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:background="?attr/colorPrimary" />

    <su.gamepoint.opendomofon.pro.sliding.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="2dp"
        android:background="@color/ColorPrimary" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1">
    </android.support.v4.view.ViewPager>

</LinearLayout>
</android.support.v4.widget.DrawerLayout>

Upvotes: 1

Views: 81

Answers (2)

Md. Al- Rasel
Md. Al- Rasel

Reputation: 71

You can do it two ways.

Firstly by xml: You can set different dimens for different API level and set padding in your AppBar.

Secondly by java: Create a method like below

 public int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}

then in your onCreate() :

   set this padding on your Appbar.

Upvotes: 1

Shabbir Dhangot
Shabbir Dhangot

Reputation: 9121

This is because you set android:fitsSystemWindows="true".

android:fitsSystemWindows attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

Either you can remove this line or set it to false

Upvotes: 0

Related Questions