I am creating a toolbar. I have everything in place, but I am unable to get rid of the gaps that occur on both sides as well as the top. It seems to be mimicking the gaps of listview,which is underneath it. I know that I can delete the padding attributes in the relative layout. The problem is that when I do that, the listview's layout (which is at the bottom of the toolbar) changes along with it and I want it to be the way it is. Does anybody have suggestions on how to get rid of those unwanted gaps while keeping the layout of the rest of my activity?
Here is my xml layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
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.jesse.myapp.FavoriteActivity">
<include
layout="@layout/favoritebar"
android:id="@+id/fb"/>
<ListView
android:id="@+id/languageselector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="false" />
<TextView
android:id="@+id/checkboxtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/emptyElement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="NO FAVORITES AVAILABLE"
android:textColor="#525252"
android:textSize="19.0sp"
android:visibility="gone" />
<Button
android:id="@+id/checklist"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@mipmap/arrow2"
android:gravity="end"
android:text=""/>
</RelativeLayout>
and the xml file for the toolbar:
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:theme= "@style/Toolbarstyle">
</android.support.v7.widget.Toolbar>
This should work if you want the relative layout content as it is:
<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/favoritebar"
android:id="@+id/fb"/>
<RelativeLayout 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/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
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.jesse.myapp.FavoriteActivity">
<ListView
android:id="@+id/languageselector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="false" />
<TextView
android:id="@+id/checkboxtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/emptyElement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="NO FAVORITES AVAILABLE"
android:textColor="#525252"
android:textSize="19.0sp"
android:visibility="gone" />
<Button
android:id="@+id/checklist"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@mipmap/arrow2"
android:gravity="end"
android:text=""/>
</RelativeLayout>
</LinearLayout>