I created few static chips in a group. I'm using this link (https://material.io/design/components/chips.html#) as reference. Code is as given below:
<RelativeLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:background="#android:color/white"
android:gravity="bottom"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="9dp">
<ImageView
android:id="#+id/sendBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:paddingTop="4dp"
app:srcCompat="#drawable/chatbot_send_btn" />
<EditText
android:id="#+id/queryEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="#+id/sendBtn"
android:imeOptions="actionSend"
android:inputType="text"
android:paddingTop="4dp"
android:textSize="18sp" />
<com.google.android.material.chip.ChipGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_above="#id/queryEditText">
<com.google.android.material.chip.Chip
style="#style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd" />
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd"
style="#style/Widget.MaterialComponents.Chip.Choice"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd"
style="#style/Widget.MaterialComponents.Chip.Choice"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd"
style="#style/Widget.MaterialComponents.Chip.Choice"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd"
style="#style/Widget.MaterialComponents.Chip.Choice"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wsfdsd" />
</com.google.android.material.chip.ChipGroup>
</RelativeLayout>
This doesn't display all chips, it displays only 1 chip. How can I add hoizontal scrolling? do I need to display chips dynamically so that I can add horizontal scrolling?
just put on horizontalScrollView and set android:scrollbars="none"
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<com.google.android.material.chip.ChipGroup
android:id="#+id/chipsPrograms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:chipSpacing="8dp"
app:singleSelection="true" />
</HorizontalScrollView>
You can put the ChipGroup inside an HorizontalScrollView
Related
horizontal scroll with overlay imageview (https://i.stack.imgur.com/5DgQw.png)
Xml code :
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:clickable="true"
app:fabSize="normal"
app:srcCompat="#drawable/player2_demo"
/>
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideOverlay"
android:layout_toRightOf="#+id/done"
android:layout_marginLeft="10dp"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:overScrollMode="always"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:scrollbars="horizontal">
<com.google.android.material.chip.ChipGroup
android:id="#+id/chipGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:chipSpacingHorizontal="15dp"
app:itemSpacing="15dp">
<com.google.android.material.chip.Chip
android:id="#+id/chip1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chip featured"
android:textSize="15dp" />
<com.google.android.material.chip.Chip
android:id="#+id/chip2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chip_players"
android:textSize="15dp" />
<com.google.android.material.chip.Chip
android:id="#+id/chip3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chip_food"
android:textSize="15dp" />
<com.google.android.material.chip.Chip
android:id="#+id/chip4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chip_exploreby"
android:textSize="15dp" />
<com.google.android.material.chip.Chip
android:id="#+id/chip5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="chip_kids"
android:textSize="15dp" />
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
I am using floating action button for imageview and horizontal scrollview to acheive horizontal scrolling inside that i'm using chipgroups.
when i scrool horizontally it should be scrolled to match parent with overlay image.
I am trying to make all my checkboxes in the same vertical column in my XML file of the android project.
The result and code is given;
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<CheckBox
android:id="#+id/cannamon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cinnamon"
android:textSize="18sp" />
<CheckBox
android:id="#+id/nutmeg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutmeg"
android:textSize="18sp" />
<CheckBox
android:id="#+id/nutella"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutella"
android:textSize="18sp" />
<CheckBox
android:id="#+id/whipped_cream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="18sp" />
</LinearLayout>
I think the constraints of the linear layout are correct.
Or should I use the Grid layout?
You should use ConstraintLayout. I think you wanted to achieve something like below:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="CheckBox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="CheckBoxTest"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/checkBox" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout
>
Plenty of ways to do it. Here's an example:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left">
<CheckBox
android:id="#+id/cannamon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cinnamon"
android:textSize="18sp" />
<CheckBox
android:id="#+id/nutmeg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutmeg"
android:textSize="18sp" />
<CheckBox
android:id="#+id/nutella"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutella"
android:textSize="18sp" />
<CheckBox
android:id="#+id/whipped_cream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
What you are currently doing is aligning the center of each CheckBox view to the center. Since each CheckBox is not the same width, the boxes will not line up. What you can do is align everything to the left, then wrap this LinearLayout in another which centers it. Here is an example:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckBox
android:id="#+id/cannamon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cinnamon"
android:textSize="18sp"/>
<CheckBox
android:id="#+id/nutmeg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutmeg"
android:textSize="18sp"/>
<CheckBox
android:id="#+id/nutella"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nutella"
android:textSize="18sp"/>
<CheckBox
android:id="#+id/whipped_cream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="18sp"/>
</LinearLayout>
Remove android:gravity="center" from linearlayout from your xml code
i achieved the following Layout for my bottom sheet:
but i am not satisfied about the implementation. I used a dummy fab which is invisible so that the title can align to it. The visible fab is outside of the layout with the title.
Without the dummy fab the title is too long (sometimes) and is placed under the fab. I couldn't figure out how to get this layout without the dummy fab.
Here is my layout.xml by far:
<?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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/titleLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/ColorPrimary">
<TextView
android:id="#+id/markerTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/bottom_sheet_navigation_dummy"
android:layout_toStartOf="#+id/bottom_sheet_navigation_dummy"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#color/white"
android:padding="#dimen/defaultPadding"
android:maxLines="1"/>
<com.github.clans.fab.FloatingActionButton
android:id="#+id/bottom_sheet_navigation_dummy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="#drawable/ic_navigation_white_24dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:theme="#style/MenuButtonsStyle"/>
</RelativeLayout>
<TextView
android:id="#+id/markerAdressLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="#string/address"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/markerAdress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:textSize="14sp" />
<TextView
android:id="#+id/markerTelephoneNumberLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="#string/telephone"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/markerTelephoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:textSize="14sp" />
<TextView
android:id="#+id/markerOpeningHoursLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="#string/opening_hours"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/markerOpeningHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:textSize="14sp" />
<TextView
android:id="#+id/markerWebsiteLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="#string/website"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/markerWebsiteLabel2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="#string/more_information"
android:textSize="14sp" />
<TextView
android:id="#+id/markerWebsite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:textSize="14sp" />
</LinearLayout>
<com.github.clans.fab.FloatingActionButton
android:id="#+id/bottom_sheet_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="#drawable/ic_navigation_white_24dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:theme="#style/MenuButtonsStyle"/>
Can anyone share a smarter solution for my layout?
Thanks in advance!
I would take the RelativeLayout with the title and the title itself out of the LinearLayout and make them siblings of the Fab Button.
This way you can tell the TextView to be "layout_toLeftOf="#+id/bottom_sheet_navigation". Then you will need to make sure, that the background of the text (your RelativeLayout) still stretches all the way to the right. Unfortunately you will still need an invisible dummy TextView for this, which needs to have the same parameters (padding, textSize) as your title.
<?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">
<!--Title background-->
<RelativeLayout
android:id="#+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent">
<!--Dummy Textview which is required to provide the correct height for the background
"#id/titleLayout"
It has the same parameters as ""#id/markerTitle""-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:padding="#dimen/defaultPadding"
android:maxLines="1"
android:background="#color/colorAccent"
android:visibility="invisible"/>
</RelativeLayout>
<!--The title with the correct allignment-->
<TextView
android:id="#+id/markerTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#color/white"
android:padding="#dimen/defaultPadding"
android:maxLines="1"
android:background="#color/colorAccent"
android:layout_toLeftOf="#+id/bottom_sheet_navigation"
android:text="This is a super long title. 123456"/>
<!--The info LinearLayout needs to be placed below the title-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/markerTitle"
android:orientation="vertical">
<!--...-->
</LinearLayout>
<com.github.clans.fab.FloatingActionButton
android:id="#+id/bottom_sheet_navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="#drawable/ic_navigation_white_24dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:theme="#style/MenuButtonsStyle"/>
</RelativeLayout>
Inside a linearLayout I have put three RelativeLayouts with weight = 1. I want RelativeLayouts to be in the center of the screen. How can I manage their position?
below is my xml code:
<LinearLayout
android:id="#+id/layout_circular_items"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view_bg_profile_img"
android:padding="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:background="#color/color_backgrounds_light">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_txt_view"
android:layout_margin="8dp"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="#+id/txt_view_scores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2843"
android:textSize="#dimen/dim_txt_size_times"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
<TextView
android:id="#+id/txt_view_scores_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="scores"
android:layout_below="#id/txt_view_scores"
android:textSize="#dimen/dim_txt_size_times_title"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_txt_view"
android:layout_margin="8dp"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="#+id/txt_view_purchase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12"
android:textSize="#dimen/dim_txt_size_times"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
<TextView
android:id="#+id/txt_view_purchase_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="purchase"
android:layout_below="#id/txt_view_purchase"
android:textSize="#dimen/dim_txt_size_times_title"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_txt_view"
android:layout_margin="8dp"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="#+id/txt_view_cash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="21450"
android:textSize="#dimen/dim_txt_size_times"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
<TextView
android:id="#+id/txt_view_cash_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cash"
android:layout_below="#id/txt_view_cash"
android:textSize="#dimen/dim_txt_size_times_title"
android:gravity="center"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</LinearLayout>
and this is the screen shot of output:
I want the red spaces be equal.
In your top LinearLayout
simply use android:gravity="center"
It will definitely work. If it does not work remove all gravity from RelativeLayout. Only use android:gravity="center" in top LinearLayout.
You can try to this code and edit according your need
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/layout_circular_items"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:gravity="center">
<TextView
android:id="#+id/txt_view_scores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="2843" />
<TextView
android:id="#+id/txt_view_scores_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txt_view_scores"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="scores" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:gravity="center">
<TextView
android:id="#+id/txt_view_purchase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="12" />
<TextView
android:id="#+id/txt_view_purchase_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txt_view_purchase"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="purchase" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center">
<TextView
android:id="#+id/txt_view_cash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="21450" />
<TextView
android:id="#+id/txt_view_cash_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txt_view_cash"
android:layout_centerHorizontal="true"
android:foregroundGravity="center"
android:gravity="center"
android:text="cash" />
</RelativeLayout>
</LinearLayout>
Although this question is answered correctly but just want to add more explanation.
When you want to change the children positions you must work with their parent gravity, No need to change the children gravity. In your case you must simply change your LinearLayout's gravity to center or center_horizontal like this:
<LinearLayout
android:id="#+id/layout_circular_items"
android:layout_width="0dp"
android:layout_height="wrap_content"
<!-- Add this line-->
android:gravity="center"
> ...
android:gravity is the Inside gravity of that View. This means, in
which direction it's contents should align.
This link is also useful to find more info about gravity and layout_gravity:
Gravity and layout_gravity on Android
I have two tabs and in the second tab I have content which is larger than the viewport, so I need ScrollView. However, I can't get ScrollView to show all content. It cuts the view at the last ~10/20dp. Here's my TabFragment.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dikte glas (mm)"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp" />
<TextView
android:id="#+id/seekBarValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_alignParentEnd="true">
</TextView>
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="200"
android:layout_marginTop="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_below="#+id/seekBarValue"/>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="20dp"
android:layout_marginRight="8dp"
android:layout_below="#id/seekBar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/soakTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Soak time"
android:textStyle="bold"
/>
<TextView
android:id="#+id/txtResultStep1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_below="#id/card_view1">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/initialCooling"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Initial Cooling"
android:textStyle="bold"
android:textSize="18sp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="#android:color/darker_gray"
android:layout_below="#id/initialCooling"/>
<TextView
android:id="#+id/rate1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rate"
android:layout_below="#id/initialCooling"
android:layout_marginTop="16dp"
/>
<TextView
android:id="#+id/txtResultStep2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/rate1"
/>
<TextView
android:id="#+id/range1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Range"
android:layout_below="#id/rate1"
android:layout_marginTop="8dp"
/>
<TextView
android:id="#+id/txtResultStep3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/range1"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_below="#id/card_view2">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/secondCooling"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2nd Cooling"
android:textStyle="bold"
android:textSize="18sp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="#android:color/darker_gray"
android:layout_below="#id/secondCooling"/>
<TextView
android:id="#+id/rate2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rate"
android:layout_below="#id/secondCooling"
android:layout_marginTop="16dp"
/>
<TextView
android:id="#+id/txtResultStep4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/rate2"/>
<TextView
android:id="#+id/range2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Range"
android:layout_below="#id/rate2"
android:layout_marginTop="8dp"
/>
<TextView
android:id="#+id/txtResultStep5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/range2"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_below="#id/card_view3">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/thirdCooling"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3rd Cooling"
android:textStyle="bold"
android:textSize="18sp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="#android:color/darker_gray"
android:layout_below="#id/thirdCooling"/>
<TextView
android:id="#+id/rate3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rate"
android:layout_below="#id/thirdCooling"
android:layout_marginTop="16dp"
/>
<TextView
android:id="#+id/txtResultStep6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/rate3"/>
<TextView
android:id="#+id/range3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Range"
android:layout_below="#id/rate3"
android:layout_marginTop="8dp"
/>
<TextView
android:id="#+id/txtResultStep7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="#id/range3"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_below="#id/card_view4">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/totalMinimumTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total minimum time"
android:textStyle="bold"
/>
<TextView
android:id="#+id/txtResultStep8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:width="120dp"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Above in the following image you can see what happens when I have my cursor in the ScrollView. The blue line is just above the navigation bar.
Under is what happens when I have my cursor in the RelativeLayout inside ScrollView (which is how it's supposed to be):
Android Studio
Could someone tell my why the ScrollView is not showing all my content?
This is how it is on the emulator.
Emulator
I've fixed it by using NestedScrollView instead of ScrollView, because the fragment is initiated in a CoordinatorLayout. I didn't know that only NestedScrollVew would work then.
Here's an answer to a year old question. But I had the same problem not being able to scroll for the last few dps. I also had a android:layout_marginTop on my top element with content. Changing that to a android:paddingTop on the ScrollView solved it for me.
I wanted to suggest this in a comment but my reputation isn't high enough. First of all, is the first screenshot what you see in the emulator or in android studio?
EDIT: Sorry just saw the names of the links. You already answer that question.
Try removing the scrollview from the RelativeLayout. If everything is contained in the scrollView, you shouldn't need the layout. I feel like the outside relativeLayout's "match_parent" fields for both width and height are problematic. Worth a shot.