Scrollview contains viewpager and one linearlayout - android

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>

Related

Include Layout Over Top Scroll to AppBarLayout in Android

I create Layout which consists
CoordinatorLayout
AppBarLayout
CollapsingToolbarLayout
Image
Toolbar
and include one layout for content.
Why the content layout when scroll up is over the toolbar?
This is pic first open Activity
This is pic first open Activity
when scroll down
and scroll up
main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".Activity_Movie">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:srcCompat="#drawable/a_poster_joker" />
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_activity__movie" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
content_activity__movie.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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/Movie_Nested"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="false"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".Activity_Movie"
tools:showIn="#layout/p__movie">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:orientation="vertical">
<TextView
android:id="#+id/Movie_Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Title"
android:textColor="#color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:orientation="horizontal">
<LinearLayout
android:layout_width="160dip"
android:layout_height="200dip"
android:orientation="horizontal"
android:padding="5dip">
<ImageView
android:id="#+id/Movie_Img"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:srcCompat="#tools:sample/avatars[3]" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dip"
android:orientation="vertical"
android:padding="10dip">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Score"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<com.mancj.slimchart.SlimChart
android:id="#+id/slimChart"
android:layout_width="80dip"
android:layout_height="80dip"
app:roundedEdges="true"
app:strokeWidth="8dp"
app:text="0"
app:textColor="#color/colorAccent" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Genre"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Genre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ACTION"
android:textColor="#color/colorBlack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Release Date"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Release"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2019-11-02"
android:textColor="#color/colorBlack" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sinopsis"
android:textColor="#color/colorBlack"
android:textStyle="bold" />
<TextView
android:id="#+id/Movie_Sinopsis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=". . . . . "
android:textColor="#color/colorBlack" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:orientation="horizontal"
android:padding="5dip">
<TextView
android:id="#+id/Movie_Label_Other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Movie Action Lainnya"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:animationCache="true"
android:elevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="5dip"
android:orientation="horizontal">
<GridView
android:id="#+id/Movie_Grid"
android:layout_width="1050dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:columnWidth="100dip"
android:elevation="5dip"
android:gravity="center"
android:horizontalSpacing="5dip"
android:numColumns="10"
android:scrollbars="horizontal"
android:stretchMode="none"
android:verticalSpacing="5dip" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
use this tag into toolbar :
app:layout_scrollFlags="scroll|enterAlways|snap"
hope it will help you.

The view is not a child of CoordinatorLayout

I am getting java.lang.RuntimeException: Unable to start activity java.lang.IllegalArgumentException: The view is not a child of CoordinatorLayout.working with bottom sheet, I have tried lot of combination but still i am not getting solution. please tell me any solution.Thank you in advance.
<?xml version="1.0" encoding="utf-8"?>
<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:id="#+id/beyprod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/toolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
</LinearLayout>
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/bottom_sheet_behavior" />
</LinearLayout>-->
<android.support.v4.widget.NestedScrollView
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/bottom_sheet_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".retailerModule.cart.activity.AddressListActivity">
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relaLaySearch"
android:layout_gravity="center|top"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/confirmBtn"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<TextView
android:id="#+id/addNewAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="right"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="40dp"
android:background="#color/green"
android:gravity="center"
android:padding="10dp"
android:text="New Address"
android:textColor="#color/colorWhite" />
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/continueBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="right"
android:background="#color/color_blue"
android:gravity="center"
android:text="SAVE"
android:textColor="#color/colorWhite"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
When i tried to run this line getting exception
NestedScrollView mBehavior = BottomSheetBehavior.from(bottom_sheet);
It tells you that you can only put a BottomSheetBehavior into a CoordinatorLayout.
So make CoordinatorLayout as your root layout and place it directly here (not in some nested views)

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>

layout file not showing recyclerView items in 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>

ScrollView in second panel not working

I have an Activity that uses AndroidSlidingUpPanel. Now, everything works perfect. However, I would like to add a ScrollView on my second panel to add the same functionality like Maps or Google Music:
For instance,
When the user has a list of directions, he/she may pull up the drawer and scroll the complete instructions.
Now, my attempt:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<ScrollView
android:id="#+id/card_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:clickable="true"
android:focusable="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_slide"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="10dp"
android:text="#string/slide_up"
android:textSize="14sp" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_nutrition_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
This, displays fine my content, but does not add the scroll view for the second panel.
What can I do?
Note: According to the documentation of AndroidSlidingUpPanel, there can only be two children under its view. I use a LinearLayout as the second child because its the only way that I have found to display the drawer. For instance, that TextView would be in the place of the content of the estimated time (drawer) from Maps.
Thanks
Height of second scrollview should be android:layout_height="match_parent". Good luck!
take one RelativeLayout in com.sothree.slidinguppanel.SlidingUpPanelLayout and set property layout_above="yoursecondLinearlayout" to First ScrollView and second child LinearLayout to set property alignParentBottom=true. thats it....
See below code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
**<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >**
<ScrollView
android:id="#+id/card_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
**android:layout_above="#+id/linearlayout1"**>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
**android:id="#+id/linearlayout1"**
**android:layout_alignParentBottom="true"**
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:clickable="true"
android:focusable="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_slide"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="10dp"
android:text="#string/slide_up"
android:textSize="14sp" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_nutrition_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
Fixed it by adding an id to the Parent of the Title, and adding this to my code:
layout.setDragView((LinearLayout) findViewById(R.id.scrolled_view));
New .xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<ScrollView
android:id="#+id/card_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:clickable="true"
android:focusable="false"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/scrolled_view"
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_slide"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="10dp"
android:text="#string/slide_up"
android:textSize="14sp" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/food_nutrition_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:animateLayoutChanges="true" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

Categories

Resources