Reputation: 9374
I'm trying to set the height of the recycler view, but I have always the toolbar which is trasparent over the recycler view, and I'm trying to use the android:paddington
it doesn't help a lot
here is how it looks now
So how it would be possible to fix that
Here is my code :
<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=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:id="@+id/linearLayout">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" />
</RelativeLayout>
and my toolbar xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Upvotes: 1
Views: 901
Reputation: 668
Make some changes in layout relation like as bellow code:
android:layout_below="@+id/toolbar" on my_recycler_view
<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=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:id="@+id/linearLayout">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="fill_parent"
android:layout_below="@+id/toolbar"
android:layout_height="fill_parent"
android:scrollbars="vertical" />
</RelativeLayout>
Upvotes: 1
Reputation: 20513
You are using RelativeLayout as parent layout, change it to vertical LinearLayout and your views will not overlap.
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
Upvotes: 3