Add multiple ListView lists in one single layout in Android - android

I am trying to add 3 or more lists in a layout xml. I didn't expect this to be a problem, but I don't see all the lists(and they get populated) and the view does not scroll. I need an opinion to what stupid stuff I am doing here, please.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/googleDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white" >
<RelativeLayout
android:id="#+id/navigationHeader"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/wallpaper"
android:paddingTop="16dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="#dimen/activity_horizontal_margin"
android:orientation="vertical" >
<EditText
android:id="#+id/searchTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search" />
<TextView
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_green_light"
android:text="Hello, user"
android:textColor="#android:color/white"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_blue_light"
android:text="description"
android:textColor="#android:color/white" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:id="#+id/scrollojt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/navigationHeader"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/activity_horizontal_margin" >
<View
android:id="#+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:background="#1f000000" />
<TextView
android:id="#+id/questionsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/separator"
android:text="#string/questions_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/questionsTitle"
android:background="#android:color/holo_green_dark"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/appsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList"
android:text="#string/apps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/appsTitle"
android:background="#android:color/holo_red_dark"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/groupsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList2"
android:text="#string/groupapps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/groupsTitle"
android:background="#android:color/holo_blue_bright"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/dmTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/drawerList3"
android:text="#string/directapps_label"
android:textAllCaps="true"
android:textColor="#android:color/black" />
<ListView
android:id="#+id/drawerList4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dmTitle"
android:background="#android:color/holo_green_light"
android:clickable="true"
android:focusableInTouchMode="true"
android:scrollbars="vertical" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Use just one ListView with an ArrayAdapter.
how to use arrayadapter
If you need help customizing the array adapter, just search on google or ask me ;)

Related

Android layout with fixed button on bottom

I have the following xml which is supposed to be something similar to the following
The activity shows mostly ok, but i cant get the two down buttons to get fixed to the bottom of the screen without messing the top views.
I've tried to use a FrameLayout with two RelativeLayouts, alignment_bottom, an empty view with weight 1 between components and even still havent being able to accomplish my goal. Any help will be really appreciated, thank you in advance.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RelativeLayout1">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="#+id/description_text"
android:layout_below="#id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/mainColor"
android:textSize="20sp"
android:text="#string/descripcion"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
/>
<TextView
android:layout_below="#id/description_text"
android:gravity="start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_description"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:textSize="15sp"/>
<TextView
android:layout_below="#id/group_info_description"
android:scrollbars="vertical"
android:gravity="center"
android:textColor="#android:color/black"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:layout_marginBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_user_number"
android:textSize="15sp"
/>
<es.tretornesp.clickerchat.NonScrollableListView
android:layout_below="#id/group_info_user_number"
android:id="#+id/group_info_user_list"
android:layout_height="match_parent"
android:divider="#drawable/list_divider"
android:dividerHeight="1px"
android:layout_width="match_parent"/>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/borrar_grupo"
android:background="#color/mainColor" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/grey"/>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:text="#string/salir"
android:background="#color/mainColor"
/>
</LinearLayout>
</LinearLayout>
Change your layout file as below,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/exit_group">
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<TextView
android:id="#+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_image"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="#string/descripcion"
android:textColor="#color/mainColor"
android:textSize="20sp" />
<TextView
android:id="#+id/group_info_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/description_text"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:gravity="start"
android:textSize="15sp" />
<TextView
android:id="#+id/group_info_user_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_description"
android:layout_marginBottom="2dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:scrollbars="vertical"
android:textColor="#android:color/black"
android:textSize="15sp" />
<es.tretornesp.clickerchat.NonScrollableListView
android:id="#+id/group_info_user_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/group_info_user_number"
android:divider="#drawable/list_divider"
android:dividerHeight="1px" />
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/group_info_user_list"
android:background="#color/mainColor"
android:text="#string/borrar_grupo" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/delete_group"
android:background="#color/grey" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/mainColor"
android:text="#string/salir"
android:textColor="#android:color/white" />
</RelativeLayout>
Use Coordinator Layout as a parent layout. like this.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
// your code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="#+id/txt_contact_laksha_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="demo"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

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!

Android Layout with Scrollview not at bottom - Fragment

What am I doing wrong that I can't get my "toolbar" to show up at the bottom of the screen (the free and post buttons)? I'm having to wrap this all inside a scroll view so that the keyboard will shift the view when displayed.
=======
UPDATE: Sorry I should have stated that the FREE and POST buttons must be at the bottom of the screen and maintain their size.
This is a FRAGMENT and the mainActivity has been set to android:windowSoftInputMode="adjustResize|adjustPan" however keyboard display is not scrolling the either.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CreateFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/red">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/puregreen"
android:id="#+id/createTopView"
android:clickable="false">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/createRecylerView" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:hint="Title"
android:textSize="24sp"
android:id="#+id/createTitleTextView"
android:layout_below="#+id/createRecylerView"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:hint="Description"
android:textSize="18sp"
android:id="#+id/createDescriptionTextView"
android:layout_below="#+id/createTitleTextView"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="+ Tags"
android:id="#+id/createTagsTextView"
android:textSize="18sp"
android:layout_above="#+id/createBottomToolbar"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:id="#+id/createBottomToolbar"
android:layout_alignParentEnd="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FREE"
android:background="#drawable/button_rounded"
android:id="#+id/createCoinButton"
android:layout_alignParentLeft="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POST"
android:id="#+id/createPostButton"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:background="#color/my_blue" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
I have changed some code please try this code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/createTopView"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:clickable="false">
<android.support.v7.widget.RecyclerView
android:id="#+id/createRecylerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:layout_below="#+id/createRecylerView">
<EditText
android:id="#+id/createTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/createRecylerView"
android:hint="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24sp" />
<EditText
android:id="#+id/createDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/createTitleTextView"
android:hint="Description"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<EditText
android:id="#+id/createTagsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/createBottomToolbar"
android:text="+ Tags"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<LinearLayout
android:orientation="horizontal"
android:id="#+id/createBottomToolbar"
android:layout_width="match_parent"
android:weightSum="1"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/createCoinButton"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="match_parent"
android:text="FREE" />
<Button
android:id="#+id/createPostButton"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="POST"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Your toolbar is wrapped in a RelativeLayout which is wrapped in another RelativeLayout of which layout_height is set to wrap_content, here it is:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/red">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" <!-- here -->
android:background="#color/puregreen"
android:id="#+id/createTopView"
android:clickable="false">
Try changing this to match_parent and see if it works.
Why not use linearLayout as the child of scrollView? And set fillViewport property of the scrollView to true to stretch it's contents. Try this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".CreateFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#color/red">
<LinearLayout
android:id="#+id/createTopView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/puregreen">
<android.support.v7.widget.RecyclerView
android:id="#+id/createRecylerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/createTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24sp" />
<EditText
android:id="#+id/createDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Description"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<EditText
android:id="#+id/createTagsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="+ Tags"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<RelativeLayout
android:id="#+id/createBottomToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/createCoinButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/button_rounded"
android:text="FREE"
android:textSize="14sp" />
<Button
android:id="#+id/createPostButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="#color/my_blue"
android:text="POST"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>

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 modify layout to display input field when keyboard is shown?

I use the following layout
<?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="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:id="#+id/wizard4_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:scrollbars="vertical"
android:text="#string/wizard4_title"
android:textColor="#0088cc"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="0dp"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/wizard4_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text1"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_name"
android:hint="#string/wizard4_name_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/wizard4_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text3"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_address"
android:hint="#string/wizard4_address_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<Button
android:id="#+id/wizard4_btn_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_back" />
<Button
android:id="#+id/wizard4_btn_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_next" />
</LinearLayout>
</LinearLayout>
It is displayed as part of ViewAnimator:
viewAnimator = new ViewAnimator(this);
...
View step4 = View.inflate(getBaseContext(), R.layout.wizard4, null);
viewAnimator.addView(step4);
setContentView(viewAnimator);
When user clicks on the second input field (wizard4_address), soft keyboard is display, which hides the input field. Currently buttons wizard4_btn_next and wizard4_btn_back are also displayed when keyboard is shown, I don't need it. But I should keep them always at the bottom.
Try this. Hope you will get what you want.
<?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="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/wizard4_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:scrollbars="vertical"
android:text="#string/wizard4_title"
android:textColor="#0088cc"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/wizard4_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text1"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/wizard4_name_hint" />
<TextView
android:id="#+id/wizard4_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="fill_horizontal"
android:scrollbars="vertical"
android:text="#string/wizard4_text3"
android:textSize="18sp" />
<EditText
android:id="#+id/wizard4_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/wizard4_address_hint" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<Button
android:id="#+id/wizard4_btn_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_back" />
<Button
android:id="#+id/wizard4_btn_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/wizard_next" />
</LinearLayout>

Categories

Resources