ListView not Scrolling with parent LinearLayout? - android

I have a main ScrollView and then I have a child LinearLayout and that has ListView in it. I'm not sure why it is not scrolling. I read about how listview should not be inside scroll view, but I need my layout to scroll and then view the listview. I'm not sure if this is the proper approach. Please direct.
This works on my tablet with a large screen but not on my phone which has a smaller screen and you need to scroll to view the listview completely. The listview works if I use linear layout but then I don't see the listview completely because its on the bottom of the layout.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true" >
<LinearLayout
android:id="#+id/user_info"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingTop="46dp"
android:paddingLeft="24dp"
android:paddingRight="24dp" >
<Spinner
android:id="#+id/userTypeSpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<EditText android:id="#+id/fname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="First Name"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" >
<EditText android:id="#+id/lname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Last Name"/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:id="#+id/staff_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone" >
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" >
<EditText android:id="#+id/uname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Username"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/staff_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone" >
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" >
<EditText android:id="#+id/upassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/staff_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone" >
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" >
<EditText android:id="#+id/uemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Email"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/staff_permissions"
android:layout_marginTop="8dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
>
<ListView
android:id="#+id/permission_list"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:fadeScrollbars="false"
/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/addUserBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
android:padding="12dp"
android:text="#string/add_new_user"/>
</LinearLayout>

Same problem i had. This is my code. Check it out.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login"
android:gravity="center"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="250dp"
android:layout_height="270dp"
android:layout_marginTop="40dp"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/username_login" />
<EditText
android:id="#+id/username_login"
android:layout_width="200dp"
android:layout_height="30dp"
android:background="#drawable/edit_text"
android:inputType="text"
android:paddingLeft="5dp"
android:paddingTop="2dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/password_login" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Don't use scrollview as a parent. Just take scrollview inside parent layout i.e. LinearLayout or RelativeLayout.

Try to replace your ListView with LinearLayout and add same items(views) in this which you want to add in your listview

Related

Layout cut at the bottom in ScrollView

I have a ScrollView in my app and inside it I have created a Linear Layout which contains various elements but the problem is this my buttons on bottom are not displayed properly. They are cut off at bottom. I have used padding and margin but nothing has been happened. Below is my layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/light_gray">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/dp20"
android:layout_marginRight="#dimen/dp20"
android:layout_marginTop="#dimen/dp30"
android:orientation="vertical">
<ImageView
android:id="#+id/imgArticleImage"
android:layout_width="match_parent"
android:layout_height="#dimen/dp140"
android:layout_marginBottom="#dimen/dp15"
android:background="#android:color/white"
android:scaleType="fitXY"
android:src="#drawable/banner" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_grey_border_white_bg">
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp5"
android:text="#string/title"
android:textColor="#android:color/black" />
<android.support.design.widget.TextInputLayout
android:id="#+id/ettxtLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtTitle"
android:padding="#dimen/dp5"
app:counterEnabled="true"
app:counterMaxLength="100"
app:counterTextAppearance="#style/TextLimitStyle">
<android.support.design.widget.TextInputEditText
android:id="#+id/etTitile"
android:layout_width="match_parent"
android:layout_height="#dimen/dp80"
android:background="#android:color/transparent"
android:gravity="top"
android:maxLength="100" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp20"
android:background="#drawable/bg_grey_border_white_bg">
<TextView
android:id="#+id/txtTitleDes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp5"
android:text="#string/start_writing"
android:textColor="#android:color/black" />
<android.support.design.widget.TextInputLayout
android:id="#+id/ettxtLayoutDes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtTitleDes"
android:padding="#dimen/dp5"
app:counterEnabled="true"
app:counterMaxLength="1200"
app:counterTextAppearance="#style/TextLimitStyle">
<android.support.design.widget.TextInputEditText
android:id="#+id/etDescription"
android:layout_width="match_parent"
android:layout_height="#dimen/dp140"
android:background="#android:color/transparent"
android:gravity="top"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/layNew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp10"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="#+id/btnSave_draft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginRight="#dimen/dp20"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/save_draft"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnPublish_article"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/publish_your_article"
android:textColor="#android:color/white"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/layUpdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp10"
android:gravity="center"
android:orientation="horizontal"
>
<Button
android:id="#+id/btnDiscardChanges"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginRight="#dimen/dp20"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/discard_changes"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnSaveChanges"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/save_changes"
android:textColor="#android:color/white"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<ProgressBar
android:id="#+id/pBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
`
Can anyone suggest me what I have missed?
Wrap up another LinearLayout under the ScrollView and give
paddingBottom to the Second child (the second LinearLayout)
so add this to the added linearLayout :-
android:paddingBottom="20dp"
Correct order for padding :-
ScrollView
||
LinearLayout X- X -- > padding Bottom wont be applied
||
LinearLayout with paddingBottom -- > is applicable
Note :- paddingBottom and marginBottom cannot be applied to the immediate child of the ScrollView.
Remove
android:paddingBottom="#dimen/dp10"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
Just add android:paddingBottom="#dimen/dp30" into your LinearLayout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/light_gray">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/dp20"
android:layout_marginRight="#dimen/dp20"
android:layout_marginTop="#dimen/dp30"
android:orientation="vertical"
android:paddingBottom="#dimen/dp30">

scrollView with Button at Bottom of screen

I have to use a scroll view for the form data and a button that should be at the bottom of the screen. I have achieved it. but the problem is whenever the EditText gets focused and the keyboard is opened the button does not stay at the bottom of the screen it comes just above the android keyboard. I want it to be there at the bottom even when the keyboard is opened or not.
I have tried the android:fillViewport="true" with scroll view but it does not give a proper output.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/lout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="#+id/fout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="10dp">
<ImageView
android:id="#+id/fimg"
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="#drawable/addimg" />
<android.support.design.widget.TextInputLayout
android:id="#+id/vsubcusine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="10dp"
>
<EditText
android:id="#+id/add_food_title"
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title for Food"
android:inputType="text"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/vcusine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="cusine"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="0dp">
<Spinner
android:id="#+id/cusine"
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:padding="10dp" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<RadioGroup
android:id="#+id/isveg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="20dp">
<RadioButton
android:id="#+id/veg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Veg" />
<RadioButton
android:id="#+id/nonveg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Non-Veg" />
</RadioGroup>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/vfprice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="0dp"
>
<EditText
android:id="#+id/fprice"
style="#style/textbox"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="price"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/t"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="#+id/foodadd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/button"
android:text="ADD FOOD"
android:textColor="#FFF"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
In manifest, Just Add android:windowSoftInputMode="adjustPan" to your corresponding activity tag:
<activity
android:name=".YourActivity"
android:windowSoftInputMode="adjustPan">
Output:
Hope this helps.

Listview with EditText in each row , Scrollview inside FooterView of listview , adjustResize and adjustPan all working toghter

I have an one fragment in which I have ListView which has EditText in each row and inside footerview all controls are inside ScrollView when I set android:windowSoftInputMode="adjustPan" than it is not scroll my footerview form when softkeyboard open and also push up my header of activity and when I am trying to use android:windowSoftInputMode="adjustResize" it scroll footer view form but it auto scrolling my listview when any item open and lost EditText focus but my header is not move up.
Sorry I am not good in explaining but I hope any one undersatand what i want to explain. Actually i want to scroll scrollview to specific layout in footerview so that I face all these problems any one can help me ?
Thank You
Here is my fragment xml file
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/application_background">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/card_list"
android:fadingEdgeLength="0dp"
android:scrollbars="none"
android:headerDividersEnabled="false"
android:descendantFocusability="afterDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:listSelector="#android:color/transparent"
android:footerDividersEnabled="false"
android:transcriptMode="alwaysScroll" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:id="#+id/ll_footer"
android:gravity="center"
android:background="#color/colorIndicatorFill">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pay 250"
android:textColor="#color/white"
android:id="#+id/txt_pay"
android:gravity="center"
android:textSize="#dimen/fontsize_txtview_18" />
</LinearLayout>
</LinearLayout>
Here is my footerView xml of listview
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fillViewport="true"
android:isScrollContainer="true"
android:id="#+id/scrollView">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/ll_footer_card"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:id="#+id/rl_or">
<TextView
android:id="#+id/txt_or"
android:textSize="#dimen/fontsize_txtview_16"
android:singleLine="true"
android:text="#string/or"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#color/colorActiveIndicator"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_1"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/size_10"
android:layout_toLeftOf="#id/txt_or"
android:background="#color/gray_light" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_1"
android:layout_centerVertical="true"
android:paddingRight="#dimen/size_10"
android:layout_toRightOf="#id/txt_or"
android:background="#color/gray_light" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/ll_choose_other_card">
<TextView
android:layout_width="0dp"
android:layout_weight="0.9"
android:layout_height="wrap_content"
android:text="#string/choose_other_card"
android:id="#+id/txt_add_new_card"
android:textSize="#dimen/fontsize_txtview_16"
android:textColor="#color/colorActiveIndicator"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radio_add_new_crad"
style="#style/RadioButton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/ll_card_detail_form">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<LinearLayout
android:layout_width="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/ll_scan_card"
android:layout_height="wrap_content"
android:background="#drawable/round_corner_light_green">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/cards"
android:id="#+id/iv_card"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/scan_card"
android:textSize="#dimen/fontsize_txtview_16"
android:textColor="#color/color_white"
android:id="#+id/txt_scan_card"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<View
android:layout_width="#dimen/size_300"
android:layout_gravity="center"
style="#style/DividerBottomLine"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_card_number"
android:hint="#string/hint_card_number"
android:singleLine="true"
android:digits=" 1234567890"
android:inputType="number"
android:maxLength="23"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_expiry"
android:hint="#string/hint_expiry"
android:singleLine="true"
android:inputType="none"
android:imeOptions="actionNext"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<net.cachapa.expandablelayout.ExpandableLayout
android:id="#+id/expandable_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:el_duration="500"
app:el_expanded="false">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="#+id/ll_datePicker"
android:animateLayoutChanges="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/application_background"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layout_choose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<kankan.wheel.widget.WheelView
android:id="#+id/wheel_month"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#color/white"
android:layout_height="wrap_content" />
<kankan.wheel.widget.WheelView
android:id="#+id/wheel_year"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#color/white"
android:layout_height="wrap_content" />
</LinearLayout>
<widget.RippleView
android:id="#+id/ripple_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
app:rv_centered="true"
app:rv_color="#color/white"
app:rv_type="simpleRipple" >
<TextView
android:id="#+id/txt_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/round_corner_light_green"
android:text="#string/btn_Done"
android:textColor="#color/color_white"
android:textSize="#dimen/fontsize_txtview_18" />
</widget.RippleView>
</LinearLayout>
</LinearLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_cvv"
android:hint="#string/hint_cvv"
android:singleLine="true"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="4"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_name_on_card"
android:hint="#string/hint_name_on_card"
android:singleLine="true"
android:maxLength="100"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:imeOptions="actionDone"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/chk_save_card"
android:textColor="#color/text_color"
style="#style/Checkbox"
android:textSize="#dimen/fontsize_edttext"
android:text="#string/save_card" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
You can try by removing the scrollview from the footer and adding it to the fragment, and then you can use a NonScrollableListView instead of ListView.
For more reference on how to use a NonScrollableListView use this:
Non-scrollable ListView inside ScrollView
PS: Hope you are using ViewHolders inside your adapter for the ListView.
Cheers!

Scroll is not getting enabled

I have designed a signup screen in which I have a Scroll view , But Scroll view is not working.
I am not able to find why Scroll is not working , Help me with this.
Below is the code for reference:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/sign_up_profile_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#drawable/shape_rectangle_rounded_corner"
android:padding="10dp"
android:scaleType="fitXY"
android:src="#drawable/icon_avatar" />
<RelativeLayout
android:id="#+id/container_two"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/container_three"
android:layout_below="#+id/sign_up_profile_image"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/first_last_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_first_name_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_marginTop="2dp"
android:layout_weight="50"
android:hint="#string/first_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
<customviews.MaterialEditText
android:id="#+id/sign_up_last_name_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginTop="2dp"
android:layout_weight="50"
android:hint="#string/last_name_hint"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
</LinearLayout>
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_email_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/first_last_name_container"
android:hint="#string/email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000"
/>
<ui.customviews.MaterialEditText
android:id="#+id/sign_up_password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_email_edit_text"
android:hint="#string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:textSize="18sp"
app:baseColor="#363636"
app:floatingLabel="normal"
app:primaryColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/container_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/activity_vertical_margin">
<TextView
android:id="#+id/sign_up_terms_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_horizontal"
android:lineSpacingExtra="2dp"
android:lineSpacingMultiplier="1.2"
android:text="By signing up, you accept to the Terms and Conditions and Privacy Policy"
android:textColor="#6b6b6b"
android:textSize="14sp" />
<Button
android:id="#+id/sign_up_accept_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/sign_up_terms_text_view"
android:layout_marginLeft="#dimen/activity_vertical_margin"
android:layout_marginRight="#dimen/activity_vertical_margin"
android:background="#025961"
android:text="#string/accept_and_signup"
android:textColor="#android:color/white"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Try Like this, Add inside Linear layout , it will Scroll till End of the Page.
<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">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
// Your xml Code Put Here
</LinearLayout>
</ScrollView>
</Relativelayout>
solution can be change ScrollView to:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
Then you should change nested's layout height as well

how to set a button at the bottom of a screen when the parent is a scroll view?

I have a scrollView (this is a solution to support landscape computability)
and in it one child- linearLayout.
I want to pose a button at the bottom of a screen.
layout_height = match_parent is problematic as the scroll can be infinite.
How can I do this, to be compatible to all screen resolution?
this is my xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.m"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blue_bg" >
<LinearLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<com.m.view.text.mTextView
android:id="#+id/verifyHeaderText"
style="#style/textOnBg"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="50dp"
android:text="ENTER VERIFICATION CODE"
android:textAllCaps="true"
android:textColor="#android:color/white"
app:font_type="varela" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:paddingBottom="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="5dp" >
<LinearLayout
android:id="#+id/inputBox"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:background="#drawable/input_box_idle"
android:orientation="horizontal" >
<EditText
android:id="#+id/verificationCodeEditText"
style="#style/textOnBg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="- - - - -"
android:inputType="number"
android:maxLength="5"
android:textColor="#00bcfe"
android:textSize="25dp"
android:textStyle="italic" >
</EditText>
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/continueButton"
style="#style/textOnBg"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_selector"
android:text="Continue"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
this is the result on wide-screen
The button is in the bottom of the scroll which spans 3/4 of the whole screen
Add android:fillViewport="true" to your scrollview:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.m"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blue_bg"
android:fillViewport="true" >
Apply this to your layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Your scroll view -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginBottom="#dimen/ar_button_height"
android:gravity="center" >
<Button
android:id="#+id/button_at_bottom"
android:layout_width="match_parent"
android:layout_height="#dimen/ar_button_height"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:showDividers="middle" >
</Button>
</ScrollView>
</RelativeLayout>
Not sure if there is a better solution, but you could put your scroll view inside a relative layout and have your button outside the scroll view and set android:layout_alignParentBottom="true" on the button
If you want to set the button at the bottom you need to implement your layout with weight.
First of all the scrollview can only have one child layout inside it.
Secondly add your content layout inside the child layout of it, set the layout_height to 0dp, and do remember to set the weight to 1.
And at last add your button at the bottom of your content layout and set its height and set the weight to be 0.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollMain"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always"
android:background="#00000000"
android:scrollbars="none">
<LinearLayout
android:overScrollMode="always"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:background="#FFFFFF"
android:paddingTop="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</LinearLayout>
<Button android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_weight="0" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<com.m.view.text.mTextView
android:id="#+id/verifyHeaderText"
style="#style/textOnBg"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="50dp"
android:text="ENTER VERIFICATION CODE"
android:textAllCaps="true"
android:textColor="#android:color/white"
app:font_type="varela" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:paddingBottom="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="5dp" >
<LinearLayout
android:id="#+id/inputBox"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:background="#drawable/input_box_idle"
android:orientation="horizontal" >
<EditText
android:id="#+id/verificationCodeEditText"
style="#style/textOnBg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="- - - - -"
android:inputType="number"
android:maxLength="5"
android:textColor="#00bcfe"
android:textSize="25dp"
android:textStyle="italic" >
</EditText>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<Button
android:id="#+id/continueButton"
style="#style/textOnBg"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_selector"
android:text="Continue"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
USe your button here
You can use scrollView inside relativeLayout to fix your button at bottom:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/radialback">
<ScrollView android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/top_header"
>
<EditText
android:id="#+id/editmessage"
android:layout_margin="2dp"
style="#style/editView"
android:inputType="textMultiLine"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 _-.,()"
android:maxLength="500"
/>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/submitbutton"
android:text="#string/submitbutton"
style="#style/submitView"
android:layout_alignParentBottom="true" />
</RelativeLayout>

Categories

Resources