The problem is that RecyclerView with height = "wrap_content" doesn't wrap all content, but it measure height to only 2 adapter items.
Best describe this screenshots : http://imgur.com/a/ErvXT
It worked fine for me since 23.2.0 update, but now for some unknown reason stopped work.
I have tried with compile com.android.support:recyclerview-v7:23.2.0 , 23.2.1, 24.0.0 and it doesn't work on any of this versions.
Code:
Gradle:
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 93
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
dependencies {
...
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
...
}
Java:
final LinearLayoutManager layoutManagerFlavors = new LinearLayoutManager(getActivity());
recyclerViewFlavors.setLayoutManager(layoutManagerFlavors);
recyclerViewFlavors.addItemDecoration(new DividerItemDecoration(getActivity(), null));
//recyclerViewFlavors.setNestedScrollingEnabled(false);
FlavosAdapter flavorsAdapter = new FlavosAdapter(getActivity(), new ArrayList<Flavor>());
recyclerViewFlavors.setAdapter(flavorsAdapter);
XML:
<LinearLayout
android:id="#+id/linear_layout_fragment_liquids_views_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<TextView
android:id="#+id/liquid_name"
style="#style/TextViewStyleTitle"
android:text="#string/liquid_name"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
android:visibility="gone" />
<TextView
android:id="#+id/liquid_description"
style="#style/TextViewStyleTitle"
android:text="#string/liquid_description"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_target_big" />
<TextView
style="#style/TextViewTitleBig"
android:text="#string/liquid_target" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="#style/TextViewStyleTitleTwo"
android:drawableLeft="#drawable/ic_target_liquid"
android:text="#string/liquid_amount" />
<TextView
style="#style/TextViewStyleTitleTwo"
android:drawableLeft="#drawable/ic_nicotine_strength"
android:text="#string/liquid_str" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_ml"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_ml"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="[ml]"
android:text="10" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_strength"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_strength"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="[mg/ml]"
android:text="6" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<TextView
style="#style/TextViewStyleTitle"
android:drawableLeft="#drawable/ic_vpg"
android:text="#string/liquid_subtitle_target_ratio"
android:textSize="16sp" />
<app.minimize.com.seek_bar_compat.SeekBarCompat
android:id="#+id/slider_target"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="20dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_vg"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_vg"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="VG [%]" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_target_pg"
style="#style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="#+id/edit_text_target_pg"
style="#style/EditTextInteger"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="PG [%]" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_margin="8dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/ic_flavors_big" />
<TextView
style="#style/TextViewTitleBig"
android:text="#string/liquid_flavors_title" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_flavors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="vertical">
<ImageButton
android:layout_marginBottom="2dp"
android:id="#+id/image_button_add_flavor"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="#00000000"
android:src="#drawable/ic_add" />
<ImageButton
android:layout_marginTop="2dp"
android:id="#+id/image_button_add_flavor_from_database"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="#00000000"
android:src="#drawable/ic_add_flavor_from_database" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_name"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="5">
<AutoCompleteTextView
android:id="#+id/edit_text_flavor_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/hint_flavor_name"
android:inputType="text"
android:textSize="15sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_percentage"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="2">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_percentage"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="[%]" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_vpg"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_vpg"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="PG[%]"
android:text="100" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout_flavor_price"
style="#style/TextInputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="#+id/edit_text_flavor_price"
style="#style/EditTextFloatingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_price_for_10ml" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="8dp"
android:layout_weight="1"
android:background="#color/textColorSecondary" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:id="#+id/result_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_recipe_big" />
<TextView
android:id="#+id/text_view_recipe"
style="#style/TextViewTitleBig"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/liquid_recipe_title" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:id="#+id/text_view_show_results"
style="?android:attr/buttonStyleSmall"
android:layout_width="110dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/showresults"
android:text="#string/liquid_button_show_results"
android:textColor="#color/textColorWhite" />
<ToggleButton
android:id="#+id/image_button_toggle_chart"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="#drawable/toggle_chart"
android:textOff=""
android:textOn="" />
<ImageButton
android:id="#+id/image_button_show_save"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_save_recipe" />
<ImageButton
android:id="#+id/image_button_show_share"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_share_liquid" />
<ImageButton
android:id="#+id/image_button_show_settings"
style="?android:attr/borderlessButtonStyle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/ic_settings" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView_blender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_blender" />
<RelativeLayout
android:id="#+id/results_titles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
<TextView
android:id="#+id/result_row_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/linearLayout2"
android:text="#string/results_name"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/result_row_percentage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="[%]"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result_row_ml"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[ml]"
android:textSize="18sp"
android:textStyle="bold" />
<me.grantland.widget.AutofitTextView
android:id="#+id/result_row_drips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:maxLines="1"
android:singleLine="true"
android:gravity="right"
android:text="#string/result_drips_title"
android:textSize="16sp"
android:textStyle="bold"
autofit:minTextSize="10sp" />
<TextView
android:id="#+id/result_row_weight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[g]"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result_row_cost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="right"
android:text="[$]"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_results"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<lecho.lib.hellocharts.view.PieChartView
android:id="#+id/chart"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
<LinearLayout
android:id="#+id/linear_layout_consume_batch"
android:visibility="gone"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/ask_if_consume_flavors_from_batch" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:layout_weight="1"
android:text="#string/cancel"
android:id="#+id/button_cancel_consume"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:layout_weight="1"
android:text="#string/consume"
android:id="#+id/button_apply_consume"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<Space android:layout_height="50dp"
android:layout_width="match_parent" />
</LinearLayout>
Item View
<?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="20dp">
<TextView
android:id="#+id/result_row_name"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/linearLayout"
android:layout_toStartOf="#+id/linearLayout"
android:maxLines="1"
android:singleLine="true"
android:text="Name"
android:textSize="18sp"
/>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="230dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="right">
<TextView
android:id="#+id/result_row_percentage"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="50.0"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_ml"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="100.0"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_drips"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:maxLength="6"
android:text="3"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_weight"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:maxLength="6"
android:text="3"
android:textSize="14sp" />
<TextView
android:layout_marginLeft="2dp"
android:id="#+id/result_row_cost"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="1"
android:gravity="right"
android:text="10.5"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
Related
I have this RelativeLayout
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.StoreVisitActivity">
<ScrollView
android:id="#+id/scrollable"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/_8sdp"
android:layout_marginRight="#dimen/_8sdp"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:orientation="horizontal">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:layout_width="#dimen/_55sdp"
android:layout_height="#dimen/_55sdp"
android:src="#drawable/person" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_4sdp"
android:text="Paul Phoenix"
android:textColor="#color/main_blue"
android:textSize="#dimen/_14sdp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_4sdp"
android:text="PX2350"
android:textColor="#color/main_blue"
android:textSize="#dimen/_10sdp"
android:textStyle="bold" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
<ImageView
android:layout_width="#dimen/_60sdp"
android:layout_height="#dimen/_30sdp"
android:layout_gravity="center"
android:src="#drawable/company_logo" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_8sdp"
android:layout_marginBottom="#dimen/_2sdp"
android:background="#drawable/bg_border_radius"
android:orientation="vertical"
android:padding="#dimen/_16sdp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_20sdp"
android:layout_marginTop="#dimen/_4sdp"
android:background="#color/main_blue"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="Day, Date"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_4sdp"
android:background="#color/black_5"
android:orientation="horizontal"
android:padding="#dimen/_8sdp">
<TextView
android:id="#+id/txtTanggal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="0"
android:textAllCaps="true"
android:textSize="#dimen/_7sdp" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/input_search"
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/rectangle_input"
android:hint="Search Name Outlet"
android:inputType="text"
android:paddingHorizontal="#dimen/_10sdp"
android:textSize="#dimen/_7sdp" />
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:cardBackgroundColor="#color/blue_1"
app:cardCornerRadius="#dimen/_8sdp"
app:cardUseCompatPadding="true">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="#+id/btnSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/_8sdp">
<ImageView
android:layout_width="#dimen/_15sdp"
android:layout_height="#dimen/_15sdp"
android:src="#drawable/ic_search" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_20sdp"
android:background="#color/main_blue"
android:orientation="horizontal"
android:padding="#dimen/_4sdp">
<TextView
android:id="#+id/txtNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center"
android:maxLines="1"
android:text="No"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp"
android:textStyle="normal" />
<TextView
android:id="#+id/txtQtyInbound"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Code"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
<TextView
android:id="#+id/txtDesc"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="Store Name"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
<TextView
android:id="#+id/txtQtyScan"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Address"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
<TextView
android:id="#+id/txtSelect"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Select"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
</LinearLayout>
<cz.kinst.jakub.view.SimpleStatefulLayout
android:id="#+id/stateful"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/listPlanJourney"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:itemCount="4" />
</cz.kinst.jakub.view.SimpleStatefulLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="#+id/llButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="#dimen/_8sdp"
android:layout_marginTop="#dimen/_16sdp"
android:layout_marginRight="#dimen/_8sdp"
android:layout_marginBottom="#dimen/_10sdp"
android:orientation="horizontal">
<Button
android:id="#+id/btnExit"
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_weight="1"
android:background="#drawable/rectangle_button"
android:text="Exit"
android:textAllCaps="false"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_marginLeft="#dimen/_4sdp"
android:layout_weight="1"
android:background="#drawable/rectangle_button"
android:text="Start Visit"
android:textAllCaps="false"
android:textColor="#color/white"
android:textSize="#dimen/_7sdp" />
</androidx.appcompat.widget.LinearLayoutCompat>
</RelativeLayout>
The RecyclerView may contains lots of items (say > 80), that why I put it inside a ScrollView. And I want the Buttons to stay permanent on the bottom of the screen, that's why I use android:layout_alignParentBottom="true". But when I run in, the result is not what I expect. Turns out the Buttons are actually "floating" on top of the ScrollView, like this:
What I want is the LinearLayout containing the Buttons stuck at the buttom, and the rest above it are fully occupied by the ScrollView. How to fix this?
I recommended you use ConstraintLayout and avoid nested layout as much as you can. I have modified your code as little as possible just to fit your needs like below(replace margin/padding back to your desire):
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">
<LinearLayout
android:id="#+id/layout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:src="#drawable/ic_notification" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:text="Paul Phoenix"
android:textColor="#0000FF"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:text="PX2350"
android:textColor="#0000FF"
android:textSize="10dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="#drawable/ic_notification" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="2dp"
android:background="#drawable/bg_pb"
android:orientation="vertical"
android:padding="16dp"
app:layout_constraintTop_toBottomOf="#id/layout_1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:background="#0000FF"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="Day, Date"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:background="#000000"
android:orientation="horizontal"
android:padding="8dp">
<TextView
android:id="#+id/txtTanggal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="0"
android:textAllCaps="true"
android:textSize="7dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="#id/layout_2">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/input_search"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/ic_notification"
android:hint="Search Name Outlet"
android:inputType="text"
android:paddingHorizontal="10dp"
android:textSize="7dp" />
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:cardBackgroundColor="#0000AA"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:id="#+id/btnSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_notification" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_header"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="#0000FF"
android:orientation="horizontal"
android:padding="4dp"
app:layout_constraintTop_toBottomOf="#id/layout_search">
<TextView
android:id="#+id/txtNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center"
android:maxLines="1"
android:text="No"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp"
android:textStyle="normal" />
<TextView
android:id="#+id/txtQtyInbound"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Code"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp" />
<TextView
android:id="#+id/txtDesc"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:gravity="center"
android:maxLines="1"
android:text="Store Name"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp" />
<TextView
android:id="#+id/txtQtyScan"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Address"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp" />
<TextView
android:id="#+id/txtSelect"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:maxLines="1"
android:text="Select"
android:textAllCaps="true"
android:textColor="#FFFFFF"
android:textSize="7dp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/listPlanJourney"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/llButtons"
app:layout_constraintTop_toBottomOf="#id/layout_header"
tools:itemCount="4" />
<LinearLayout
android:id="#+id/llButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/btnExit"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_weight="1"
android:background="#drawable/bg_pb"
android:text="Exit"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="7dp" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginLeft="4dp"
android:layout_weight="1"
android:background="#drawable/bg_pb"
android:text="Start Visit"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="7dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
I have one fragment whose layout i want to show above keyboard when softkeyboard opens up. The layout is:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#drawable/ic_bg_splash"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/previous"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:background="#drawable/left"
android:padding="7dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="7dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="7dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="7dp"
android:orientation="vertical">
<ImageView
android:id="#+id/subCat"
android:layout_width="157.5dp"
android:layout_height="157.5dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="50dp"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:paddingLeft="20dp"
android:text="#string/enter_answer"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
<LinearLayout
android:layout_width="262.5dp"
android:layout_height="52.5dp"
android:layout_marginTop="7dp"
android:background="#drawable/answer_bg"
android:orientation="horizontal">
<EditText
android:id="#+id/answer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="8"
android:background="#null"
android:fontFamily="#font/nunito"
android:inputType="textNoSuggestions"
android:maxLines="1"
android:padding="7dp"
android:textColor="#android:color/white"
android:textSize="15sp" />
<ImageView
android:id="#+id/wrong_answer"
android:layout_width="27.5dp"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:src="#drawable/red_cross"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:layout_marginBottom="27dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:text="#string/reset"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14.3sp" />
<TextView
android:id="#+id/submit_ans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:background="#drawable/white_rounded"
android:fontFamily="#font/nunito_semibold"
android:paddingLeft="17dp"
android:paddingTop="7dp"
android:paddingRight="17dp"
android:paddingBottom="7dp"
android:text="#string/submit"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="14.3sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/next"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="22dp"
android:background="#drawable/right" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/write_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:elevation="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/write_success"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I have tried by setting windowssoftinputmode to adjustResize in manifest and also using fitsystemwindows to true in the fragment parent layout but still it is not working and using scrollview as parent layout instead of relativelayout. So please suggest me any workaround for this issue.
Edit: Added below activity.xml layout:
Below is the host activity layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/language_bg"
android:orientation="vertical"
tools:context=".home.HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bottom_rounded">
<RelativeLayout
android:id="#+id/taskBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_weight="1.7"
android:paddingLeft="30dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="143dp"
android:layout_height="56dp"
android:layout_gravity="left|center_vertical"
android:src="#drawable/hello_logo" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/learn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:src="#drawable/learn_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/learn"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/learn_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor" />
</LinearLayout>
<LinearLayout
android:id="#+id/practice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="42dp"
android:layout_height="28dp"
android:src="#drawable/practice_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/practice"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/practice_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:layout_marginRight="30dp"
android:layout_weight="1.3"
android:gravity="right"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/unlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="26.5dp"
android:layout_height="32dp"
android:src="#drawable/unlock_blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/unlock"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center_horizontal|bottom"
android:orientation="vertical">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_marginTop="2dp"
android:src="#drawable/language" />
<TextView
android:id="#+id/language_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="#string/lang"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/appbar_practice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="12dp"
android:visibility="gone">
<LinearLayout
android:id="#+id/read_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="23.5dp"
android:layout_height="17.5dp"
android:background="#drawable/icon_read" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/read"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/read_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/speak_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="16.5dp"
android:layout_height="21.5dp"
android:background="#drawable/icon_speak" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/speak"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/speak_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/listen_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="18.5dp"
android:layout_height="18.5dp"
android:background="#drawable/icon_listen" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/listen"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/listen_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/write_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="17dp"
android:layout_height="19dp"
android:background="#drawable/icon_write" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/write"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/write_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Try to put your scrollView into relative Layout.
After commenting this from my activity onCreate() it started working:
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
I need to make a list in my NestedScrollView but showing only first element. I tried with android:fillViewport="true" but hothing happened. I know that ListView has scrollable incorporated in itself.
my xml :
<layout >
<data>
<variable
name="home"
type="com.nswd.successplan.ui.fragments.homeFragment.HomeViewModel" />
</data>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f4f7"
android:fillViewport="true"
tools:context=".ui.fragments.homeFragment.HomeFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#f0f4f7">
<TextView
android:id="#+id/dashboard_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:gravity="center"
android:text="Dashboard"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/first_row_LL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent" />
<LinearLayout
android:id="#+id/first_row_LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/date_time_LL"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dashboard_TV">
<LinearLayout
android:id="#+id/my_plan_LV"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:background="#0f5acf"
android:onClick="#{home::updateMyPlanOnClick}"
android:orientation="vertical"
android:padding="2dp">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:src="#drawable/ic_assignment" />
<TextView
android:id="#+id/home_fragment_update_my_plan_TV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Update My Plan"
android:textColor="#ffffff"
android:textSize="11sp"
tools:ignore="SmallSp" />
</LinearLayout>
<LinearLayout
android:id="#+id/update_my_budget_LV"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:background="#4d88ff"
android:baselineAligned="false"
android:onClick="#{home::updateMyBudgetOnCLick}"
android:orientation="vertical"
android:padding="2dp">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:src="#drawable/ic_baseline" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Update My Budget"
android:textColor="#ffffff"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>
<LinearLayout
android:id="#+id/contact_advisor_LV"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#0e4087"
android:onClick="#{home::contactAdvisorOnCLick}"
android:orientation="vertical"
android:padding="2dp">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:src="#drawable/ic_contact_support" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Contact advisor"
android:textColor="#ffffff"
android:textSize="11sp"
tools:ignore="SmallSp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/date_time_LL"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="8dp"
android:background="#884dff"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/second_row_LL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/first_row_LL">
<ImageView
android:id="#+id/date_image_IMG"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/ic_date_range_24" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="00:00"
android:textColor="#ffffff"
android:textSize="24sp" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="29.09.2020"
android:textColor="#ffffff"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/second_row_LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/pie_chart_expenditures_TV"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/date_time_LL">
<LinearLayout
android:id="#+id/plan_last_update_LV"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical"
android:padding="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Plan Last Updated"
android:textColor="#color/hints_black"
android:textSize="10sp"
tools:ignore="SmallSp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="21"
android:textColor="#3297e9"
android:textSize="28sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Aug 2017"
android:textColor="#a0b4bf"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/until_retirement_LV"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical"
android:padding="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Until Retirement"
android:textColor="#color/hints_black"
android:textSize="10sp"
tools:ignore="SmallSp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="33"
android:textColor="#3297e9"
android:textSize="28sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Years"
android:textColor="#a0b4bf"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/out_of_debt_LV"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical"
android:padding="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Out of Debt Date"
android:textColor="#color/hints_black"
android:textSize="10sp"
tools:ignore="SmallSp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="20"
android:textColor="#3297e9"
android:textSize="28sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Aug 2017"
android:textColor="#a0b4bf"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/pie_chart_expenditures_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#ffffff"
android:gravity="center"
android:text="Monthly Expenditures"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/pie_chart_expenditures_LL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/second_row_LL" />
<LinearLayout
android:id="#+id/pie_chart_expenditures_LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/list_view_pie_chart_legend"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/pie_chart_expenditures_TV">
<com.github.mikephil.charting.charts.PieChart
android:id="#+id/pie_chart_reports_home"
android:layout_width="match_parent"
android:layout_height="400dp" />
</LinearLayout>
<ListView
android:id="#+id/list_view_pie_chart_legend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/pie_chart_expenditures_LL"
tools:listitem="#layout/pie_chart_list_item" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
my item view:
<layout>
<data>
<variable
name="legend"
type="com.nswd.successplan.model.PieChartLegendModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:padding="4dp">
<ImageView
android:id="#+id/legend_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_dot_list_item_pie_chart" />
<TextView
android:id="#+id/expenditure"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="Debt Payments"
android:textColor="#197ad8" />
<TextView
android:id="#+id/costs_expenditure"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:text="7,555" />
</LinearLayout>
</layout>
I have designed layout by taking the reference from this and code for the same is below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/action_bar_color"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="#+id/txt_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="#dimen/image_margin_left"
android:text="#string/app_name"
android:textColor="#android:color/black"
android:textSize="#dimen/login_txt_size" />
<ImageView
android:id="#+id/img_refresh"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_action_refresh" />
<ImageView
android:id="#+id/img_setting"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_action_settings" />
<ImageView
android:id="#+id/img_wifi"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_wifi_on"
android:tint="#color/button_theme_color" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="#+id/tv_home_networkStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#003b60"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="Medium Text"
android:textColor="#FFFF0000"
android:textSize="20sp"
android:visibility="visible" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="#drawable/logo_login" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/round_masjid_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="#drawable/masjid" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="#drawable/user_sep" />
<EditText
android:id="#+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="#null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/round_kiosk_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#null"
android:padding="20dp"
android:src="#drawable/tablet" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="#drawable/pass_sep" />
<EditText
android:id="#+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="#null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
<Button
android:id="#+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
And code of manifest is below
<activity android:name=".activity.LoginActivity"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan|adjustResize">
</activity>
But still it gives output like . When soft keyboard is appearing buttons are hiding below of the soft keyboard.I have tried by using adjustResize as well as adjustPan,but still no change in output.I have added ScrollView too If anyone is having the solution please help
Try this make ScrollView as parent root layout like below code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/action_bar_color"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="#+id/txt_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="#dimen/image_margin_left"
android:text="#string/app_name"
android:textColor="#android:color/black"
android:textSize="#dimen/login_txt_size" />
<ImageView
android:id="#+id/img_refresh"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_action_refresh" />
<ImageView
android:id="#+id/img_setting"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_action_settings" />
<ImageView
android:id="#+id/img_wifi"
android:layout_width="#dimen/logo_image_w"
android:layout_height="#dimen/logo_image_h"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/image_margin_left"
android:background="#drawable/custom_image_click"
android:src="#drawable/ic_wifi_on"
android:tint="#color/button_theme_color" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="#+id/tv_home_networkStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#003b60"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="Medium Text"
android:textColor="#FFFF0000"
android:textSize="20sp"
android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="50dp"
android:src="#drawable/logo_login" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/round_masjid_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:src="#drawable/masjid" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="#drawable/user_sep" />
<EditText
android:id="#+id/edt_clientid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="#null"
android:hint="Client ID"
android:inputType="number"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/round_kiosk_corner"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#null"
android:padding="20dp"
android:src="#drawable/tablet" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="#drawable/pass_sep" />
<EditText
android:id="#+id/edt_device_code"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="#null"
android:hint="Device Code"
android:inputType="text"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Login"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
<Button
android:id="#+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/custom_button_frag_menu"
android:padding="20dp"
android:text="Cancel"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:textSize="35sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
than apply android:windowSoftInputMode="adjustResize" in manifest file to your activity
NOTE: - fullscreen mode doesn't resize
Please have a look at the below UI (please ignore the comment in red)
Below is my attempt in making it
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/content_id_target_ranges"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".activities.TargetRangesActivity"
tools:showIn="#layout/app_bar_target_ranges">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/target_ranges_title_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="12dp"
android:text="#string/my_settings_target_ranges"
android:textSize="20sp" />
<TextView
android:id="#+id/target_ranges_sub_heading_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:text="#string/target_ranges_sub_heading"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="12dp"
android:background="#drawable/linear_border"
android:orientation="vertical">
<TextView
android:id="#+id/target_ranges_blood_glucose_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="12dp"
android:text="#string/target_ranges_blood_glucose_text"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="15dp"
android:layout_marginTop="6dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/target_ranges_blood_glucose_pre_meal_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/target_ranges_blood_glucose_pre_meal"
android:textAlignment="center"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/target_ranges_blood_glucose_pre_meal_unit_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="#string/target_ranges_blood_glucose_unit"
android:textAlignment="center"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_first_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_second_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_third_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="34dp"
android:layout_height="48dp"
android:textSize="16sp"
android:textColor="#color/colorWhite"
android:background="#drawable/gray_colour_style"
android:layout_weight="1.46" />
<TextView
android:layout_width="90dp"
android:layout_height="48dp"
android:textSize="16sp"
android:background="#drawable/green_colour_style"
android:textColor="#color/colorWhite"
android:layout_weight="0.15" />
<TextView
android:layout_width="60dp"
android:layout_height="48dp"
android:textSize="16sp"
android:background="#drawable/yellow_colour_style"
android:textColor="#color/colorWhite" />
<TextView
android:layout_width="70dp"
android:layout_height="48dp"
android:textSize="16sp"
android:background="#drawable/red_colour_style"
android:textColor="#color/colorWhite"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/target_ranges_blood_glucose_post_meal_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/target_ranges_blood_glucose_post_meal"
android:textAlignment="center"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/target_ranges_blood_glucose_post_meal_unit_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="#string/target_ranges_blood_glucose_unit"
android:textAlignment="center"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_four_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_five_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/edit_text_style">
<EditText
android:id="#+id/target_ranges_blood_glucose_six_edit"
style="#style/EditTextStyle"
android:focusable="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="24dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
However it generated the below UI
Notice how the colorfull bar is not aligned properly with the upper and lower text boxes, as the first image indicated via a dotted line (the dotted line shows the where the edge of each colourful tile should be, in aligned with the textboxes.
Also notice my text boxes are different than what is expected.
How can I make it as displayed in the first image?
Here I have fix your inner layout, change drawable and color.., etc
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/content_id_target_ranges"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/down_shadow"
android:orientation="vertical"
android:weightSum="20">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Texttttttttttttttttttttttttttttttttt"
android:textColor="#000" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="10">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="#+id/pre_meal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="kkk lkjl" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pre_meal"
android:gravity="center"
android:text="sd/sd" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8"
android:orientation="horizontal"
android:weightSum="6">
<EditText
android:id="#+id/one"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<EditText
android:id="#+id/two"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<EditText
android:id="#+id/three"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="9">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1.5"
android:background="#8c9393"
android:gravity="center"
android:text="Low"
android:textColor="#fff" />
<TextView
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="2.4"
android:background="#1dea12"
android:gravity="center"
android:text="Normal"
android:textColor="#fff" />
<TextView
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="2.2"
android:background="#f5d904"
android:gravity="center"
android:text="High"
android:textColor="#fff" />
<TextView
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1.9"
android:background="#ea0c05"
android:gravity="center"
android:layout_marginRight="2dp"
android:text="Very High"
android:textColor="#fff" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="10">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="#+id/pre_meals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="kkk lkjl" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pre_meals"
android:gravity="center"
android:text="sd/sd" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8"
android:orientation="horizontal"
android:weightSum="6">
<EditText
android:id="#+id/four"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<EditText
android:id="#+id/five"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<EditText
android:id="#+id/six"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#999698"
android:focusable="true" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Instead of Edittext use your TextInput layout. It is giving error while compiling so i changed it to Edittext