I have one outer ScrollView in which there is one RecyclerView and three tabs. Every tab has a fragment and that fragment loads in corresponding tab using ViewPager but outer ScrollView does not scroll my layout. I used nested ScrollView but it also does not scroll. Maybe I did something wrong. Does any one have a suggestion? Please share with me.
Here is my xml code structure
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/parent_scroll"
android:layout_weight="1"
android:background="#color/business_price_bg"
android:focusableInTouchMode="false">
<RelativeLayout
android:id="#+id/business_detail_main_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/activity_main_search_top_main_ll"
android:layout_width="match_parent"
android:layout_height="#dimen/activity_main_search_top_main_ll_height"
android:background="#color/location_setting_bottom_button_color"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
<RelativeLayout
android:id="#+id/business_detail_activity_business_slider_main_rl"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#+id/activity_main_search_top_main_ll">
<android.support.v7.widget.RecyclerView
android:id="#+id/business_detail_activity_slider_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</RelativeLayout>
<TextView
android:id="#+id/business_detail_activity_business_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/business_detail_activity_business_slider_main_rl"
android:layout_margin="10dp"
android:text=""
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/business_detail_activity_business_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/business_detail_activity_business_title"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text=""
android:textSize="13sp" />
<android.support.design.widget.TabLayout
android:id="#+id/business_detail_activity_tabslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/business_detail_activity_business_description"
android:background="#android:color/transparent"
app:tabIndicatorColor="#color/pencilin_orange_color"
app:tabIndicatorHeight="5dp"
app:tabTextAppearance="#style/MyTabLayoutTextAppearance" />
<android.support.v4.view.ViewPager
android:id="#+id/business_detail_activity_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/business_detail_activity_tabslayout"
android:background="#android:color/white" />
</RelativeLayout>
</ScrollView>
You are going against the Android's UI Standards that's why you can never achieve your goals. Try to stick with Android UI Standards and make less complex UI.
I changed my screen Layout Structure and finally ScrollView is working
Here is solution:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<LinearLayout
android:id="#+id/business_detail_main_rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:id="#+id/activity_main_search_top_main_ll"
android:layout_width="match_parent"
android:layout_height="#dimen/activity_main_search_top_main_ll_height"
android:layout_weight="0."
android:background="#color/location_setting_bottom_button_color"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.45"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/business_detail_activity_business_slider_main_rl"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#+id/activity_main_search_top_main_ll">
<android.support.v7.widget.RecyclerView
android:id="#+id/business_detail_activity_slider_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scrollbars="vertical" />
</RelativeLayout>
<TextView
android:id="#+id/business_detail_activity_business_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/business_detail_activity_business_slider_main_rl"
android:layout_margin="10dp"
android:text=""
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/business_detail_activity_business_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/business_detail_activity_business_title"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text=""
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/business_preview_screen_services_btn"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.88"
android:background="#android:color/transparent"
android:text="#string/business_preview_screen_services_btn_str"
android:textAllCaps="false" />
<View
android:id="#+id/business_preview_screen_service_btn_seperator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.12"
android:background="#color/location_setting_bottom_button_color" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/business_preview_screen_about_btn"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.88"
android:background="#android:color/transparent"
android:text="#string/business_preview_screen_services_btn_about_btn_str"
android:textAllCaps="false" />
<View
android:id="#+id/business_preview_screen_about_btn_seperator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.13"
android:background="#color/light_gray_section_cell_seperator" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/business_preview_screen_staff_btn"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.88"
android:background="#android:color/transparent"
android:text="#string/business_preview_screen_services_btn_staff_btn_str"
android:textAllCaps="false" />
<View
android:id="#+id/business_preview_screen_staff_btn_seperator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.13"
android:background="#color/light_gray_section_cell_seperator" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:orientation="vertical">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Related
The below is my xml file in which i want a linearlayout to be in bottom i.e. layout gravity bottom. But it is not working.
Even after looking all solutions given for this type of problem, i am not able to solve it. Please Help
<?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:orientation="vertical">
<include layout="#layout/toolbar_layout" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" //----> not working
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/total"
android:textStyle="bold" />
<TextView
android:id="#+id/textViewTotalPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$23.00" />
</LinearLayout>
<Button
android:id="#+id/buttonCheckout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:drawableEnd="#drawable/ic_arrow_forward"
android:paddingEnd="15dp"
android:text="#string/checkout"
android:textColor="#color/white" />
</LinearLayout>
This is the way i want.
Try this
<?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:orientation="vertical">
<include layout="#layout/toolbar_layout" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewCart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="total"
android:textStyle="bold" />
<TextView
android:id="#+id/textViewTotalPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$23.00" />
</LinearLayout>
<Button
android:id="#+id/buttonCheckout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:background="#color/colorPrimary"
android:drawableEnd="#drawable/ic_arrow_forward"
android:paddingEnd="15dp"
android:text="#string/checkout"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
Put Space layout between RecyclerView and LinearLayout
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
or use RelativeLayout instead of your main LinearLayout
Try this code.. and change this
<?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:orientation="vertical">
<include layout="#layout/toolbar_layout" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="tees"
android:textStyle="bold" />
<TextView
android:id="#+id/textViewTotalPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$23.00" />
</LinearLayout>
<Button
android:id="#+id/buttonCheckout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:paddingEnd="15dp"
android:text="Hello" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
I am considering about the white blank spacing.
I don't know the reason why white spacing exist in my gridview.
I attached '.xml' and the 'result screen shot. '
I am trying use the gravity things.. but It dosen't work.
Could anyone help me??
...I got stackoverflow error 'It looks like your position is mostly code...
<?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="#fff"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="0.2">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/set_border"
android:gravity="center"
android:text="#string/msg_diary_plan"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.53"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/btn_backmonth"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#android:color/transparent"
android:text="" />
<TextView
android:id="#+id/tv_date"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="0.8"
android:background="#android:color/transparent"
android:gravity="center"
android:paddingLeft="10dp"
android:textColor="#000"
android:textSize="20sp" />
<Button
android:id="#+id/btn_nextmonth"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#android:color/transparent"
android:text="" />
</LinearLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.85"
android:listSelector="#ffff"
android:numColumns="7" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_alarm"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.17"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:orientation="vertical"
android:weightSum="1">
<Switch
android:id="#+id/sw_alarm"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Alarm" />
</LinearLayout>
<TimePicker
android:id="#+id/timePicker"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:timePickerMode="spinner" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1">
<Button
android:id="#+id/btn_alarm_submit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:text="SUBMIT"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
and the result is
and this is the gridview item layout. Thanks
<?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:orientation="vertical"
android:weightSum="1">
<TextView
android:id="#+id/tv_item_gridview"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.8"
android:textColor="#000" />
<TextView
android:id="#+id/isDone"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:visibility="visible" />
It is because you have yout item layout set to match_parent but TextViews to wrap_content. So by default it stays at the start position.
To fix this set your TextViews width to match_parent and gravity to center android:gravity="center"
So your item layout will look as below:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="#+id/tv_item_gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
android:gravity="center"
tools:text="2"
android:textColor="#000" />
<TextView
android:id="#+id/isDone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:gravity="center"
tools:text="13"
android:visibility="visible" />
</LinearLayout>
This is the ui which i have to create . I need scrolling when user fill the edit text but the button has to stay at the bottom . the whole view get mixed up please help me . view will scroll and all ui will be not collapse
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/frag_login_edt_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<EditText
android:id="#+id/frag_login_edt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/frag_login_edt_email"
android:layout_marginTop="#dimen/dp_10"
android:layout_weight="1"
/>
<TextView
android:layout_marginTop="#dimen/dp_30"
android:layout_below="#+id/frag_login_edt_password"
android:id="#+id/frag_login_tv_forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/frag_login_txt_forgot_password"
android:textSize="18sp" />
<include
layout="#layout/social_integration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/frag_login_button_continue_as_guest"
android:id="#+id/include" />
<Button
android:layout_marginTop="#dimen/dp_20"
android:id="#+id/frag_login_button_continue_as_guest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:textColor="#android:color/white" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#android:color/white"
android:layout_above="#+id/include"
android:layout_alignParentStart="true"
android:layout_marginBottom="21dp"
android:id="#+id/button" />
</RelativeLayout>
</RelativeLayout>
INclude Code thcode is common so i include it
<?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"
android:orientation="vertical"
android:paddingTop="#dimen/activity_horizontal_margin">
<LinearLayout
android:id="#+id/frag_login_ll_or"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<View
android:id="#+id/frag_view_one"
android:layout_width="#dimen/dp_30"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/frag_view_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp_10"
android:layout_marginRight="#dimen/dp_10"
android:layout_toRightOf="#id/frag_view_one"
android:text="OR" />
<View
android:layout_width="20dp"
android:layout_height="1dp"
android:layout_toRightOf="#id/frag_view_two"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/frag_login_ll_or"
android:layout_marginTop="#dimen/dp_20">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/facebook" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/google" />
</LinearLayout>
</RelativeLayout>
THis is activity\
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_content"
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="0dp"
android:layout_weight="0.7"
android:background="#drawable/bg">
<include
layout="#layout/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.3">
<include layout="#layout/view_pager" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/todoDetailsCoordinatorLayout"
android:background="#color/windowBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/todoEditMainLl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/windowBackground"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/todoDetailsAppBar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/todoDetailsToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetStart="10dp"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/todoDetailsBottomLl"
android:layout_below="#+id/todoDetailsAppBar"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/todoDetailsScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/todoEditTopLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/windowBackground"
android:orientation="vertical"
android:visibility="visible">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/eight_dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/list_item_single_line_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_user"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center_vertical"
android:orientation="vertical">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditTodoTxtAssignToName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="" />
<com.strait.solvenow.Utilities.WithoutSecondaryTextView
android:id="#+id/EditTodoTxtAssignByName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:src="#drawable/todo_due_date" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditToDoTxtDueDate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:background="#null"
android:gravity="left|center"
android:text="#string/Due_Date" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/todoDetailsImgStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/user_place_holder" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/EditToDoTxtStatus"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:background="#null"
android:gravity="left|center"
android:text="#string/Status" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:gravity="center|left"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_notification" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:orientation="horizontal">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/todoDetailsTxtNotify"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/Notifications" />
<android.support.v7.widget.SwitchCompat
android:id="#+id/todoEditTglNotification"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/ten_dp"
android:layout_toRightOf="#+id/todoDetailsTxtNotify"
android:background="#android:color/transparent"
android:button="#null"
android:checked="false"
android:text=""
android:textColor="#color/textColorWithoutPrimary"
android:textOff=""
android:textOn="" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:orientation="horizontal">
<LinearLayout
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/todoEditImgAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/todo_new_attach" />
</LinearLayout>
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtAttachment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center|left"
android:text="#string/Attachment" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/todo_details_height"
android:layout_marginLeft="#dimen/list_item_content_left_padding"
android:gravity="center|left"
android:orientation="horizontal">
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtReminder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Reminder"
android:visibility="visible" />
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtForward"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Forward" />
<com.strait.solvenow.Utilities.WithoutPrimaryTextView
android:id="#+id/chatEditTxtRejected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/todoEditImgAttachment"
android:layout_weight="1"
android:gravity="center|left"
android:text="#string/Reject" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- <android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/todoSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/chatWindowBottomRl">
-->
<android.support.v7.widget.RecyclerView
android:id="#+id/todoRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/five_dp"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/ten_dp"
android:visibility="visible"></android.support.v7.widget.RecyclerView>
<!--</android.support.v4.widget.SwipeRefreshLayout>-->
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/todoDetailsBottomLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<include
android:id="#+id/todoChatBottomVerticalLine"
layout="#layout/divider_view_line"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:background="#color/windowBackground"
android:paddingLeft="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_vertical_margin"
android:visibility="visible">
<ImageView
android:id="#+id/todoChatImgAttachment"
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="#dimen/icon_padding"
android:src="#drawable/chat_attachment"
android:visibility="visible" />
<com.strait.solvenow.Utilities.WithoutEditTextView
android:id="#+id/todoChatEdtTextMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/five_dp"
android:layout_toLeftOf="#+id/todoChatImgSend"
android:layout_toRightOf="#+id/todoChatImgAttachment"
android:background="#drawable/chat_window_text_msg_bg"
android:hint=""
android:maxLines="4"
android:minHeight="35dp"
android:paddingLeft="#dimen/ten_dp"
android:text=""
android:textSize="16sp"
android:visibility="visible" />
<ImageView
android:id="#+id/todoChatImgSend"
android:layout_width="#dimen/avatar_icon_touch_area_size"
android:layout_height="#dimen/avatar_icon_touch_area_size"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="#dimen/icon_padding"
android:src="#drawable/send"
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I have using recycle view inside nested Scroll view but Recycle view not scroll down in nested scroll view.recycle view scroll down when keyboard open and new item add in recycle view.here is above my code.
First of all this is bad layout technique you have implement
According to android standard there are no more than two Scrolling views inside one layout
Make a proper layout for same
You should disable scrolling of recyclerview :
recycler.setNestedScrollingEnabled(false);
You should also set height of recyclerview to wrap_content
android:layout_height="wrap_content"
How to put RecyclerView inside NestedScrollView?
I want to display a scroll view within ViewPager and action buttons below the ViewPager. So I set android:layout_weight="1" to ViewPager, but it was not displayed, and only action buttons was displayed.
The layout of ViewPager is following.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingBottom="10dp"
android:text="この記事の投稿者に" />
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="メールで問い合わせ" />
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="電話で問い合わせ" />
</LinearLayout>
</LinearLayout>
The layout within ViewPager is following.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView
android:id="#+id/title"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="21sp" />
<ImageView
android:id="#+id/image"
android:layout_height="200dp"
android:layout_width="200dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center" />
<TextView
android:id="#+id/price"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="34sp"
android:textColor="#FF0000" />
<TextView
android:id="#+id/text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="21sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
When you are using weights with Layouts you need to use a height or width, depending on the orientation, of "0dp"
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="0.8" />
<LinearLayout
android:orientation="vertical"
android:layout_height="0dp"
android:layout_width="match_parent"
android:weight="0.2">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingBottom="10dp"
android:text="この記事の投稿者に" />
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="メールで問い合わせ" />
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="電話で問い合わせ" />
</LinearLayout>
This should do the trick:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="0" />
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>