AndroidBeginnerJhon AndroidBeginnerJhon - 1 month ago 13
Android Question

Textview doesnot shows up above RecyclerView in nestedscrollview android

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView
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:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.tech.world.MainActivity"
tools:showIn="@layout/app_bar_main_activity"
android:fillViewport="true" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >

<TextView
android:id="@+id/textView"
android:textColor="#43a047"
android:typeface="serif"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/app"
android:gravity="center"
android:textStyle="bold"
android:textSize="15sp" />


<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_marginTop="10dp"
android:divider="@color/colorAccent"
android:dividerHeight="1dp" />

</RelativeLayout> </android.support.v4.widget.NestedScrollView>


now the textview above dont show up,i have to scroll a bit down to see the textview,also i am using toolbar which expands and contacts in coordinator layout due to this
app:layout_behavior="@string/appbar_scrolling_view_behavior"

i want to make sure textview is visible on start without scrolling a bit to see it

Answer

Set android:focusableInTouchMode="true" to your recycler view's parent layout i.e your relative layout.