0

I want the width of my action bar fill all the screen, Im following this tutorial but when I move the width parameters I cant fill all the width of my screen. When I use a default actionBar theme, the actionBar cover all the width of the screen, but when I create one actionBar myself I cant do it, is there anyway? This is the image of what it looks like Screenshot Edit 1 It works, the problem was the padding, so I move my both RelativeLayout and ActionBar into another RelativeLayout with this parameters and work really well, moving the second RelativeLayout below my ActionBar

<?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" android:layout_height="fill_parent" android:layout_width="fill_parent" tools:context="com.marcelo.notemuevas.MainActivity"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" android:layout_below="@id/my_toolbar"> </RelativeLayout> </RelativeLayout> 

newScreenshot

3 Answers 3

1

This happens because your action bar (or toolbar) is inside a viewgroup (relativelayout) that has padding (top, bottom, left, right). You can either move your action bar outside or adjust the paddings.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh! you are right!, I update the padding values to 0 and it fixed, It is possible to move the actionBar outside the main RelativeLayout?
Yes, it is possible although the action bar and the relativelayout must be inside another viewgroup. Adjusting paddings might be a better alternative.
1

It'll probably help if you could provide your layout xml file, so that we could help you spot the issue.

But when you create a custom action bar, it should just be like any other view i.e. you can layout your action bar the same way you layout all your other views. So try replace your action bar with a basic view and see if the issue persists. If it does, adjust your layout parameters.

Comments

1

This happens because your main layout has padding. You need to remove the padding on the layout.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.