How to set all view with inside Relatvie layout in android - android

<LinearLayout 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:orientation="vertical"
android:weightSum="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_7x"
android:paddingRight="#dimen/baseline_grid_7x"
android:paddingTop="#dimen/baseline_grid_7x">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:adapter="#{imageSlideradapter}"
app:currentItem="#{landingLoginViewModel.currentPage}"
android:addOnPageChangeListener="#{landingLoginViewModel.pageChangeListener}"/>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/indicator"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="#dimen/text_land_spacing"
android:paddingTop="#dimen/layout_padding_top"
android:text="#string/label_businesscard_title"
android:textColor="#3e4360"
android:textSize="#dimen/businees_card_textmessage_size"
android:textStyle="normal" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingTop="#dimen/padding_top_15dp"
app:centered="true"
app:fillColor="#1ebad6"
app:radius="#{landingLoginViewModel.pagerIndicatorCircle}"
app:pageColor="#c6caca"
app:snap="false" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_2.5x"
android:paddingRight="#dimen/baseline_grid_2.5x"
android:paddingTop="#dimen/baseline_grid_5x">
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/buttonbackroudnd"
android:onClick="#{()->landingLoginViewModel.onSignIn()}"
android:text="#string/label_sign_in"
android:textColor="#ffffff" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signin"
android:layout_marginTop="#dimen/baseline_grid_3.5x"
android:background="#drawable/roundbuttonborder"
android:onClick="#{()->landingLoginViewModel.onSignUp()}"
android:text="#string/label_sign_up"
android:textColor="#00becc" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/oRtextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signup"
android:layout_marginTop="#dimen/baseline_grid_5.5x"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="#string/label_or"
android:textColor="#8998a7"
android:textSize="14sp"
android:textStyle="normal"
/>
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/oRtextLabel"
android:gravity="center"
android:onClick="#{()->landingLoginViewModel.onFacebook()}"
android:orientation="horizontal"
android:layout_marginTop="#dimen/baseline_grid_5x">
<ImageView
android:layout_width="#dimen/baseline_grid_3.5x"
android:layout_height="#dimen/baseline_grid_3.5x"
android:src="#drawable/fb_icon" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:paddingLeft="#dimen/baseline_grid_1x"
android:text="#string/label_fcebook"
android:textColor="#465892"
android:textSize="#dimen/baseline_grid_2x"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
This is my Xml i have divided full Screen in two part one for with each weight 1 and 1 for first Part every thing is comming correct but for second part i am trying to display lot of Control but last item goes to down while i want to fit all control please look my screen .look my current Screen last item goes down not visibile in small size Screen while in bigger its show ing please suggest me where am doing wrong.

The RelativeLayouts inside the LinearLayout should have a height of 0dp if you are using weights.
Setting them to wrap_content doesn't garantee that the content will be out of bounds of the visible screen.

Change your RelativeLayout height to 0dp and try.

Use this xml:
<LinearLayout 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:orientation="vertical"
android:weightSum="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_7x"
android:paddingRight="#dimen/baseline_grid_7x"
android:paddingTop="#dimen/baseline_grid_7x">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:adapter="#{imageSlideradapter}"
app:currentItem="#{landingLoginViewModel.currentPage}"
android:addOnPageChangeListener="#{landingLoginViewModel.pageChangeListener}"/>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/indicator"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="#dimen/text_land_spacing"
android:paddingTop="#dimen/layout_padding_top"
android:text="#string/label_businesscard_title"
android:textColor="#3e4360"
android:textSize="#dimen/businees_card_textmessage_size"
android:textStyle="normal" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingTop="#dimen/padding_top_15dp"
app:centered="true"
app:fillColor="#1ebad6"
app:radius="#{landingLoginViewModel.pagerIndicatorCircle}"
app:pageColor="#c6caca"
app:snap="false" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_2.5x"
android:paddingRight="#dimen/baseline_grid_2.5x"
android:paddingTop="#dimen/baseline_grid_5x">
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/buttonbackroudnd"
android:onClick="#{()->landingLoginViewModel.onSignIn()}"
android:text="#string/label_sign_in"
android:textColor="#ffffff" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signin"
android:layout_marginTop="#dimen/baseline_grid_3.5x"
android:background="#drawable/roundbuttonborder"
android:onClick="#{()->landingLoginViewModel.onSignUp()}"
android:text="#string/label_sign_up"
android:textColor="#00becc" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/oRtextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signup"
android:layout_marginTop="#dimen/baseline_grid_5.5x"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="#string/label_or"
android:textColor="#8998a7"
android:textSize="14sp"
android:textStyle="normal"
/>
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/oRtextLabel"
android:gravity="center"
android:onClick="#{()->landingLoginViewModel.onFacebook()}"
android:orientation="horizontal"
android:layout_marginTop="#dimen/baseline_grid_5x">
<ImageView
android:layout_width="#dimen/baseline_grid_3.5x"
android:layout_height="#dimen/baseline_grid_3.5x"
android:src="#drawable/fb_icon" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:paddingLeft="#dimen/baseline_grid_1x"
android:text="#string/label_fcebook"
android:textColor="#465892"
android:textSize="#dimen/baseline_grid_2x"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>

Related

How to put TextView below RecyclerView in NestedScrollView in android

I want to create a layout in which cart price and the total price will be displayed below the recycler view but when text view is placed below recycler view it gets invisible
I have searched on the internet about this but didn't find any solution
when text view is below the recycler view it gets invisible
Thanks in advance
<androidx.core.widget.NestedScrollView
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:background="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_weight = "8.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_weight = "1.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:text="Total Right"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
Try this
<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">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8.5"
tools:context=".ShoppingCartActivity" />
</androidx.core.widget.NestedScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
Can you try this?
<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:layout_margin="8dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8"
tools:listitem="#layout/tek_satir_playlist" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
>
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="224dp"
android:layout_marginRight="224dp"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
First of all, you can not use weight and weightSum attributes for relative layout.
As I understand from your code You do not need to use the nested scroll, try this
<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"
android:background="#android:color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottom_container"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:id="#+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
I change the first sub Layout in androidx.core.widget.NestedScrollView to ConstraintLayout too easily position your RelativeLayout in it.
bellow is the completed code, I hope it would help...
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#+id/footer"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cartRecyclerView">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/total_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Try this code
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"/>
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:margin_top="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Cost"
android:textSize="20sp"
android:textStyle="bold|italic" />
<LinearLayout>
</androidx.core.widget.NestedScrollView>

ScrollView is not working in Linearlayout in android

Below is my xml some of layout is below which is not fit on screen so I have applied ScrollView on parent LinearLayout that linear layout is applied with weight but when I am trying to scroll that layout its not scrolling. Can any one suggest me where and what I am doing wrong why ScrollView is not working on weight LinearLayout ?
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_7x"
android:paddingRight="#dimen/baseline_grid_7x"
android:paddingTop="#dimen/baseline_grid_7x">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:adapter="#{imageSlideradapter}"
app:currentItem="#{landingLoginViewModel.currentPage}"
android:addOnPageChangeListener="#{landingLoginViewModel.pageChangeListener}"/>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/indicator"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="#dimen/text_land_spacing"
android:paddingTop="#dimen/layout_padding_top"
android:text="#string/label_businesscard_title"
android:textColor="#3e4360"
android:textSize="#dimen/businees_card_textmessage_size"
android:textStyle="normal" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingTop="#dimen/padding_top_15dp"
app:centered="true"
app:fillColor="#1ebad6"
app:radius="#{landingLoginViewModel.pagerIndicatorCircle}"
app:pageColor="#c6caca"
app:snap="false" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_2.5x"
android:paddingRight="#dimen/baseline_grid_2.5x"
android:paddingTop="#dimen/baseline_grid_5x">
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/buttonbackroudnd"
android:onClick="#{()->landingLoginViewModel.onSignIn()}"
android:text="#string/label_sign_in"
android:textColor="#ffffff" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signin"
android:layout_marginTop="#dimen/baseline_grid_3.5x"
android:background="#drawable/roundbuttonborder"
android:onClick="#{()->landingLoginViewModel.onSignUp()}"
android:text="#string/label_sign_up"
android:textColor="#00becc" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/oRtextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signup"
android:layout_marginTop="#dimen/baseline_grid_5.5x"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="#string/label_or"
android:textColor="#8998a7"
android:textSize="14sp"
android:textStyle="normal"
/>
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/oRtextLabel"
android:gravity="center"
android:onClick="#{()->landingLoginViewModel.onFacebook()}"
android:orientation="horizontal"
android:layout_marginTop="#dimen/baseline_grid_5x">
<ImageView
android:layout_width="#dimen/baseline_grid_3.5x"
android:layout_height="#dimen/baseline_grid_3.5x"
android:src="#drawable/fb_icon" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:paddingLeft="#dimen/baseline_grid_1x"
android:text="#string/label_fcebook"
android:textColor="#465892"
android:textSize="#dimen/baseline_grid_2x"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
ScrollView is working, please check below layout
Note : changed widgets, heights and paddings and have fixed height for RelativeLayout to check ScrollView
<ScrollView
android:id="#+id/scrollView1"
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:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:paddingTop="7dp">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/indicator"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="5dp"
android:paddingTop="5dp"
android:text="label_businesscard_title"
android:textColor="#3e4360"
android:textSize="5dp"
android:textStyle="normal" />
<android.support.v4.view.ViewPager
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingTop="15dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp">
<Button
android:id="#+id/btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="label_sign_in"
android:textColor="#ffffff" />
<Button
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signin"
android:layout_marginTop="5dp"
android:text="label_sign_up"
android:textColor="#00becc" />
<TextView
android:id="#+id/oRtextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signup"
android:layout_marginTop="7dp"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="label_or"
android:textColor="#8998a7"
android:textSize="14sp"
android:textStyle="normal" />
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/oRtextLabel"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/ic_launcher_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:paddingLeft="5dp"
android:text="label_fcebook"
android:textColor="#465892"
android:textSize="16dp"
android:textStyle="normal" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
Replace your xml with this one:
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:weightSum="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_7x"
android:paddingRight="#dimen/baseline_grid_7x"
android:paddingTop="#dimen/baseline_grid_7x">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:adapter="#{imageSlideradapter}"
app:currentItem="#{landingLoginViewModel.currentPage}"
android:addOnPageChangeListener="#{landingLoginViewModel.pageChangeListener}"/>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/indicator"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="#dimen/text_land_spacing"
android:paddingTop="#dimen/layout_padding_top"
android:text="#string/label_businesscard_title"
android:textColor="#3e4360"
android:textSize="#dimen/businees_card_textmessage_size"
android:textStyle="normal" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingTop="#dimen/padding_top_15dp"
app:centered="true"
app:fillColor="#1ebad6"
app:radius="#{landingLoginViewModel.pagerIndicatorCircle}"
app:pageColor="#c6caca"
app:snap="false" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="#dimen/baseline_grid_2.5x"
android:paddingRight="#dimen/baseline_grid_2.5x"
android:paddingTop="#dimen/baseline_grid_5x">
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/buttonbackroudnd"
android:onClick="#{()->landingLoginViewModel.onSignIn()}"
android:text="#string/label_sign_in"
android:textColor="#ffffff" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signin"
android:layout_marginTop="#dimen/baseline_grid_3.5x"
android:background="#drawable/roundbuttonborder"
android:onClick="#{()->landingLoginViewModel.onSignUp()}"
android:text="#string/label_sign_up"
android:textColor="#00becc" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/oRtextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_signup"
android:layout_marginTop="#dimen/baseline_grid_5.5x"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="#string/label_or"
android:textColor="#8998a7"
android:textSize="14sp"
android:textStyle="normal"
/>
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/oRtextLabel"
android:gravity="center"
android:onClick="#{()->landingLoginViewModel.onFacebook()}"
android:orientation="horizontal"
android:layout_marginTop="#dimen/baseline_grid_5x">
<ImageView
android:layout_width="#dimen/baseline_grid_3.5x"
android:layout_height="#dimen/baseline_grid_3.5x"
android:src="#drawable/fb_icon" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:paddingLeft="#dimen/baseline_grid_1x"
android:text="#string/label_fcebook"
android:textColor="#465892"
android:textSize="#dimen/baseline_grid_2x"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>

Scrollview not scrolling

I'm using a scroll view which is having only one child linearlayout.
Linearlayout contains listview and some other items also, but only listview is scrolling. what should i do ?
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Any one please help me?
Never put A ListView inside a ScrollView. It is a bad practice and it defeats the purpose of having a ListView. Who wants two scrollable areas on a screen anyway?
Instead add a header or footer view on your listView depending on what you need.
If you look at the documentation https://developer.android.com/reference/android/widget/ScrollView.html it states that scrollview should never be used with listview there may be a conflict between them.
Try this layout:
changes:
Make your inner linearlayout wrap into Scrollview
Apply android:layout_height="wrap_content" for scrollview
End the scrollview before Listview as both can not be applied together
<?xml version="1.0" encoding="utf-8"?>
<include layout="#layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
</LinearLayout>
</ScrollView>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Use NestedScrollView instead of ScrollView.
NestedScrollView is just like ScrollView, but it supports acting
as both a nested scrolling parent and child on both new and old
versions of Android.
See the Documentation
Update your XML as below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/layout_scorll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
I found the solution by using only with the listview. ie., removing scrollview, and by using headerview for the listview
Xml code for listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#drawable/list_divider"
android:dividerHeight="#dimen/dp1"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false" />
</LinearLayout>
xml code for headerview of listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/profile_background"
android:orientation="vertical">
<Button
android:id="#+id/button_sign_in"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/dp40"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-medium"
android:text="Sign in"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14sp" />
<LinearLayout
android:id="#+id/button_sign_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/dp16">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif-normal"
android:text="#string/new_to_beco"
android:textColor="#color/beco_white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="7dp"
android:fontFamily="sans-serif-normal"
android:text="#string/action_sign_up"
android:textAllCaps="true"
android:textColor="#color/beco_primary"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/profile_background">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/image_profile"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-medium"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="18sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/user_name"
android:layout_alignStart="#+id/user_name"
android:layout_below="#+id/user_name"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="13sp" />
<ImageView
android:id="#+id/action_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/email"
android:layout_alignTop="#+id/user_name"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"
android:layout_toEndOf="#+id/user_name"
android:layout_toRightOf="#+id/user_name"
android:src="#drawable/ic_edit" />
</RelativeLayout>
</ViewSwitcher>

Add RelativeLayout with buttons below RecyclerView

I need to add a RelativeLayout below my RecyclerView and was able to do so, except that the button under TOTAL(R.id.total_amount_tv) does not show:
I can easily scroll through the items and it doesn't affect my RelativeLayout. I just need the button to be visible.
<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="wrap_content"
android:background="#android:color/white"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="#+id/order_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#string/total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/total_amount_tv"
android:layout_marginTop="51dp"
android:background="#color/accent"
android:onClick="onClickSendOrder"
android:text="#string/order_btn"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
You need to divide the screen in to two Parts one for showing the Recyclerview and other for RelativeLayout
<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:background="#android:color/white"
android:orientation="vertical"
android:weightSum="10">
<android.support.v7.widget.RecyclerView
android:id="#+id/order_recycler"
android:layout_weight = "8.5"
android:layout_width="match_parent"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_weight = "1.5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:text="Total Right"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
This will produce the following results
android:layout_alignParentBottom="true"
This is the likely culprit. Both TextViews are aligned at the bottom of their parent RelativeLayout. This doesn't leave room for the Button.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/downline_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lin_result"
android:layout_marginTop="5dp" />
<LinearLayout
android:id="#+id/lin_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#f8ffffff"
android:orientation="vertical"
android:paddingBottom="10dp">
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="5dp"
android:background="#999898" />
<TextView
android:id="#+id/text_total_rupees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="100"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
</RelativeLayout>

ScrollView Not Working(It's Not Scrolling the layout)

I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Categories

Resources