This is the xml layout of the file
Here, when i made the layout the toolbar is overlapping the content of my textView, Why this is happening.
Have tried several other things but no luck..!!!
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.alpit.formula2.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="alpit isfdfsdfwefwes great jhfjhvjhhbnmbjk"
android:textSize="20dp" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/navigation_menu"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
This is my current situation.
add top margin to relativelayout like
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:weightSum="1">
I should have written this as comment but I don't have reputations so I have added it as answer
try this give margin to Textview
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.alpit.formula2.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text=" alpit isfdfsdfwefwes great jhfjhvjhhbnmbjk"
android:textSize="20dp" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/navigation_menu"
></android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Don't put hard coded values to layout you can try this,
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:text="alpit isfdfsdfwefwes great jhfjhvjhhbnmbjk"
android:textSize="?android:textAppearanceMedium" />
</RelativeLayout>
remove
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
and use into relative_layout
android:layout_marginTop="#dimen/activity_vertical_margin"
Problem is just because you have given padding to your Drawer layout and your relative layout start drawing from top which includes paddingTop also
please try below code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:weightSum="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="alpit isfdfsdfwefwes great jhfjhvjhhbnmbjk"
android:textSize="20dp" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/navigation_menu"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
also you can use parent layout as relative layout and inside these use Drawer layout
Related
How to fit the Navigation Drawer under toolbar it's overlaps the main layout.
activity_set_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:openDrawer="start"
>
<include
layout="#layout/app_bar_set_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemTextColor ="#FFFFFF"
app:headerLayout="#layout/nav_header_set_main"
app:menu="#menu/activity_set_main" />
</android.support.v4.widget.DrawerLayout>
app_bar_set_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.pash.icas_nvod.setMain">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
>
<ImageView
android:layout_width="220dp"
android:layout_height="40dp"
android:src="#drawable/bydesign_logo"
android:layout_marginRight="80dp"
android:id="#+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_set_main" />
</android.support.design.widget.CoordinatorLayout>
content_set_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="#+id/content_set_main_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#EE7F22"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.pash.icas_nvod.setMain"
>
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
</RelativeLayout>
Above are my xml files am not able make drawer fit under the toolbar.
The drawer layout is overlapping to main layout. How to i resolve it..?
I have searched alot but none of the answer relates to my problem.Thank you in advance.
You can try android:layout_below="#+id/app_bar_set_main" in your DrawerLayout.
-----OR-----
You can try to move your toolbar out of your drawerlayout. So in my project, i used LinearLayout as root layout. I tried to replace with your components, hope it helps.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<include
layout="#layout/app_bar_set_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:openDrawer="start"
>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_below="#+id/app_bar_set_main" //Add this line also.
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemTextColor ="#FFFFFF"
app:headerLayout="#layout/nav_header_set_main"
app:menu="#menu/activity_set_main" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
Edit: Also you must add android:layout_below to fit your drawer under toolbar.
I want to change the default background image of my navigation drawer.
I have a .jpg image (1600x900) in drawable folder. I set android:background="#drawable/bg_1" for LinearLayout, but when i debug the app in my device, the image doesn't appear and i have a white background.
This is my nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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:id="#+id/AccountInformation"
android:layout_width="match_parent"
android:layout_height="#dimen/nav_header_height"
android:background="#drawable/bg_1"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:weightSum="1">
<ImageView
android:id="#+id/imageView"
android:layout_width="70dp"
android:layout_height="60dp"
android:layout_weight="0.3"
android:paddingTop="#dimen/nav_header_vertical_spacing"
app:srcCompat="#drawable/contatti" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing">
<Spinner
android:id="#+id/AccountSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/AccountEmail"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" />
<TextView
android:id="#+id/AccountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android Studio"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"/>
<TextView
android:id="#+id/AccountEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="android.studio#android.com" />
</RelativeLayout>
</LinearLayout>
And this is the layout of the activity (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:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
The attibute android:background="#drawable/bg_1" should be in the NavigationView view not the LinearLayout ViewGroup.
Hope this help.
You are doing it wrong.
See you have to apply the following:
android:background="#drawable/bg_1"
to NavigationView block in the other xml file
not to linearLayout which you include as Header Layout in the navigationView
Please try a .png image for that,
or after that check a color code android:background="#651FFF".
Hope this help.
I have a little problem with my android design code, the data overlaps the toolbar:
I'm just using the navigation drawer with REST Api data adapter result. The data are represented by row.xml:
row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:clickable="false"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:focusableInTouchMode="false"
android:padding="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:orientation="vertical">
<TextView
android:id="#+id/tvMessage"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="THIS IS DATA MESSAGE"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
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:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:clickable="false"
android:visibility="visible">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lvMovies" />
</android.support.v4.widget.DrawerLayout>
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:clickable="false"
android:visibility="visible">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lvMovies" />
</android.support.v4.widget.DrawerLayout>
content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.testapp.testapp.MainActivity"
tools:showIn="#layout/app_bar_main">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:layout_marginTop="70dp"
android:layout_height="0dp"
android:layout_weight="1"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="Android Studio"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio#android.com" />
</LinearLayout>
You put your listview in wrong position.You should put it in content_main.
I added a footer to the navigation drawer in Android Studio 2.1.3 but I can't slide the menu.
It is always open and it covers the main screen, also it hides the hamburger icon.
I searched but could not find how to solve this issue.
The activity main xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
app:elevation="0dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:menu="#menu/activity_main_drawer"/>
<LinearLayout
android:id="#+id/spacer_to_bottom"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="0dp"
android:layout_weight="1"/>
<include layout="#layout/nav_footer_main">
</include>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
and the the footer xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/side_nav_bar"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/facebook"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="#drawable/fb"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/twitter"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="#drawable/twitter"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/youtube"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="#drawable/youtube"/>
</LinearLayout>
and the screenshot my app
I don't know what to do(
Why does it look thhis way? The width is match_parent. How can I remove the padings?
MainActivity.xml
However, toolber.xml looks the way I want it to look
toolbar.xml
Toolber.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="#color/colorPrimary">
</android.support.v7.widget.Toolbar>
MainActivity.xml
<?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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.android.design3.MainActivity">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"></include>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tool_bar"
android:layout_marginTop="159dp"
android:text="Hello World!" />
</RelativeLayout>
Remove these from RelativeLayout:
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
Change your Layout like..Remove all padding from your Layout
<?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"
tools:context="com.example.android.design3.MainActivity">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"></include>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tool_bar"
android:layout_marginTop="159dp"
android:text="Hello World!" />
</RelativeLayout>
Your MainActivity.xml has padding properties. They apply to all layouts children. One of them is your toolbar. Try removing paddingTop, paddingRight, paddingLeft from MainActivity.xml