layout file not showing recyclerView items in android - android

This is my payout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
It is displaying bottom card view items and toolbar. But not displaying recyclerView Items. items are available in recyclerView, But i am missing something in layout file (display part)
Can anyone help me what i am missing here?

You have not set layout_below property in cardview. That is why your recyclerview is overlapped by cardview
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:alignParentBottom="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
</RelativeLayout>

Try this..
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

try this i think it will solve your problem.....
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:layout_below="#+id/recycler_view"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

Related

How can I add top drawer and bottom navigation in android activity?

How to add top drawer and bottom tab navigation in whole application?
I tried to combine 2 activity in android studio and its causing design issue. Its not working
For the bottom navigation
https://developer.android.com/reference/android/support/design/widget/BottomNavigationView
For Top drawer exaplain a little what exactly you want
You can achieve this throughout your whole Project in this way.
Use this as an activity_main.xml like as your MainActivity.java class.
<?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_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="#dimen/dp_180"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/top_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/nav_header_height"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="#+id/userimageLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<com.team.helperclasses.CircleImageView
android:id="#+id/userimage"
android:layout_width="#dimen/dp_100"
android:layout_height="#dimen/dp_100"
android:src="#mipmap/side_menu_profile_"
app:civ_border_color="#color/colorPrimary"
app:civ_border_overlay="true"
app:civ_border_width="1dp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/editProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_lay"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/editProfileText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfileImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/editProfile"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/editProfileImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/side_menu_profile" />
</RelativeLayout>
<View
android:id="#+id/editProfiledivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/editProfile"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/sharedWall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfile"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/sharedWallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/sharedWall"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/shareWallImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/wall" />
</RelativeLayout>
<View
android:id="#+id/shareWallDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/sharedWall"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/changeLang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallDivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/changeLangText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/changeLanguage"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/changeLangImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/language" />
</RelativeLayout>
<View
android:id="#+id/changeLangdivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/changeLang"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangdivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/logoutText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/logoutImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/logout"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/logoutImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/log_out" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
& the Layout app_bar_home.xml looks like this.
<?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.team.activities.Home">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:title="#string/app_name"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:theme="#style/ToolBarStyle">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/search"
android:gravity="left"
android:text="#string/app_name"
android:textColor="#color/black"
android:textSize="#dimen/sp_22" />
<ImageView
android:id="#+id/searchHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/notificationLay"
android:src="#mipmap/search" />
<RelativeLayout
android:id="#+id/notificationLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_5">
<ImageView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp_5"
android:src="#mipmap/notification" />
<ImageView
android:id="#+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/notification"
android:padding="#dimen/dp_5"
android:src="#drawable/counter_bg" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_home" />
</android.support.design.widget.CoordinatorLayout>
& content_home.xml in which you can define the things as per your requirement in the application.
<?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_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.team.activities.Home"
tools:showIn="#layout/app_bar_home">
<RelativeLayout
android:id="#+id/fragment_space"
android:name="com.presence.fragments.HomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_lay" />
<LinearLayout
android:id="#+id/bottom_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_50"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:layoutDirection="ltr"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/tab_create"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_create"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_create"
android:layout_centerHorizontal="true"
android:src="#mipmap/create" />
<TextView
android:id="#+id/text_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/create"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_received"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_received"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_received"
android:layout_centerHorizontal="true"
android:src="#mipmap/recived" />
<TextView
android:id="#+id/text_received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/received"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_sent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_sent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_sent"
android:layout_centerHorizontal="true"
android:src="#mipmap/sent" />
<TextView
android:id="#+id/text_sent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/sent"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_website"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_website"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_travel"
android:layout_centerHorizontal="true"
android:src="#mipmap/web" />
<TextView
android:id="#+id/text_travel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/booking"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Try this hope it helps you.

Unable to add views after RecyclerView in NestedScrollView

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
How do I add the TextView after the RecyclerView in the NestedScrollView?
When I added it, it doesnt show up... However, the textView above the RecyclerView works and is visible
set android:nestedScrollingEnabled="false" in RecyclerView
replace
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:nestedScrollingEnabled="false"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
Try this code.. and change your needs according.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Hello World"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp"
android:layout_marginRight="20dp"
/>
</RelativeLayout>

Scrollview contains viewpager and one linearlayout

I tried to make a scrollable view with one ViewPager which will take 90% of the screen and then some useful information about images inside the ViewPager.
However, when I add the ScrollView widget, all sizes and weight doesn't work even if I set android:fillViewport="true". Here's my layout.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="100"
android:scrollbars="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:popupTheme="?android:attr/homeAsUpIndicator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="90"
android:orientation="vertical"
android:padding="50dip">
<android.support.v4.view.ViewPager
android:id="#+id/product_sheet_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="bbb"/>
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Ref: 2049/889/300" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Remove the android:fillViewport="true" and set the layout_height of your NestedScrollView to match_parent.
So here's the final layout should look like.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical"
android:weightSum="100">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:popupTheme="?android:attr/homeAsUpIndicator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="90"
android:orientation="vertical"
android:padding="50dip">
<android.support.v4.view.ViewPager
android:id="#+id/product_sheet_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="bbb" />
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Ref: 2049/889/300" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<?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"
>
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:layout_above="#+id/relativeLayoutBottom"
>
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerPlanDetailBroucher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="250dp"
android:numColumns="auto_fit"
android:verticalSpacing="1dp"
android:horizontalSpacing="1dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
>
</android.support.v4.view.ViewPager>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutBottom"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="bbb"/>
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/product_sheet_description"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_below="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Ref: 2049/889/300" />
</RelativeLayout>
</RelativeLayout>

actionBar is goned when input edittext

My issue is the editText on the tabLayout is child fragment , when i input edittext the actionbar will up and disappear.
I try to add the android:windowSoftInputMode="adjustPan" or add ScrollView on the fragment xml, they are no working.
I can't find the same issue on internet.
Is anyone can teach me the solution,please.
Parent page:
<?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"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<!--my actionbar is overhere-->
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!--Parent Fragment change from here-->
<FrameLayout
android:id="#+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu"
app:itemIconTint="#color/colorPrimary"/>
</android.support.v4.widget.DrawerLayout>
Child page:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
android:orientation="vertical"
tools:context=".SubpagesLayout.Homepage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#android:color/white"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:orientation="horizontal">
<ImageView
android:layout_width="80dp"
android:layout_height="80sp"
android:id="#+id/genderIcon"
android:layout_gravity="center"
android:layout_weight="1"
app:srcCompat="#drawable/photo_default_female" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light">
<TextView
android:text="Name"
android:textColor="#android:color/black"
android:textSize="30dp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginLeft="125dp"
android:id="#+id/textNameAges"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="543"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:background="#android:color/background_light"
android:layout_width="match_parent"
android:layout_height="10dp"></LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<!--Child fragment change by the TabLayouts-->
<!--body_weight_fragment is one of the tabs-->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayoutHomePage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
app:tabTextColor="#android:color/white">
</android.support.design.widget.TabLayout>
<view
android:id="#+id/viewPager"
class="android.support.v4.view.ViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</android.support.design.widget.AppBarLayout>
</LinearLayout>
body_weight_fragment:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<!--input editText will let actionbar disappear-->
<EditText
android:id="#+id/editHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="cm"
android:inputType="number"
android:windowSoftInputMode="adjustPan" />
<Button
android:id="#+id/btnCaculate"
android:layout_width="2dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#drawable/corner_pink"
android:text="caculate"
android:textColor="#android:color/white" />
<EditText
android:id="#+id/editWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="kg"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="show result"
android:paddingTop="8dp" />
</LinearLayout>
<com.github.mikephil.charting.charts.PieChart
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.github.mikephil.charting.charts.PieChart>
</LinearLayout>
try it in manifest: add (adjustResize + adjustPan) for parent activity
<activity
android:name="main"
android:windowSoftInputMode="adjustPan|adjustResize"/>
I found a solution by myself,i have to use scrollView include the toolaBar.Just like above
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</ScrollView>

EditText error tooltip position is off

I would like to have my error tooltip displayed like in this image.
But mine is off like this
How can I fix this?
My layout code is below
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".main.EditProfileActivity"
tools:showIn="#layout/activity_edit_profile">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:orientation="vertical"
android:paddingBottom="56dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/label_margin_right"
android:src="#drawable/ic_account_grey600_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editTextNickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:hint="#string/profile.nickname"
android:maxLength="16"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp" />
<Button
android:id="#+id/buttonNicknameClear"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|right"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:background="#drawable/ic_close_grey600_24dp"
android:onClick="onNicknameClearClicked"
android:padding="0dp"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/label_margin_right"
android:src="#drawable/ic_email_grey600_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editTextEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:hint="#string/profile.email"
android:inputType="textEmailAddress"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp" />
<Button
android:id="#+id/buttonEmailClear"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|right"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:background="#drawable/ic_close_grey600_24dp"
android:onClick="onEmailClearClicked"
android:padding="0dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
This happens to both first and second edit text.
What am I doing wrong?
EDIT:
I am adding extra code for more information.
This is the parent layout file.
<?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=".main.EditProfileActivity">
<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="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_edit_profile" />
</android.support.design.widget.CoordinatorLayout>
Try remove
android:paddingBottom="56dp"
Removing
app:layout_behavior="#string/appbar_scrolling_view_behavior" fixed the problem!
Thank you all!

Categories

Resources