Sticky button at the bottom of scroll view - android

I want some sticky button that is always visible when user scrolls, but when reach the bottom is fixed. I my problem is that when users scroll and reach the bottom the button overlaps some text.
This is what I have. The wrong version. The button don't let see some text in that case.
And this is what I want. That the button when you reach the end you have something like that.
This is my layout. Where I have some fields that are scrollable and the button that is outside. It's a constrain Layout.
The fields inside the scrollview are reduce to make more short the code and be easy to undersand.
<?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:fitsSystemWindows="true">
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/wf_white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:id="#+id/offers_summary_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padding_offers_layout">
<TextView
android:id="#+id/company_name"
style="#style/wf_text_copy_bold"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="ONE"/>
<TextView
android:id="#+id/product_name"
style="#style/wf_text_copy"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/company_name"
app:layout_constraintStart_toStartOf="parent"
tools:text="Compact"/>
<ImageView
android:id="#+id/logo_company"
android:layout_height="60dp"
android:layout_width="60dp"
android:layout_marginTop="#dimen/form_margins_small"
android:layout_marginEnd="#dimen/form_margins_small"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:contentDescription="#null"/>
<TextView
android:id="#+id/offer_general_info"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="end"
android:gravity="center_vertical"
app:layout_constraintStart_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view"
android:text="#string/_CS_label_general_info"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
<Button
android:id="#+id/btn_go_to_checkout"
style="#style/wf_button_primary"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/text_margin_sides"
android:layout_marginTop="#dimen/button_top_margin"
android:descendantFocusability="beforeDescendants"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/scroll_view"
android:text="#string/_OFCS_close_contract"
android:fitsSystemWindows="true"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="1.0"/>
</android.support.constraint.ConstraintLayout>

Replace this
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/wf_white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:fillViewport="true">
with this
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/wf_white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="#+id/btn_go_to_checkout"
app:layout_constraintTop_toTopOf="parent"
android:fillViewport="true">

Just add padding bottom to the second ConstraintLayout.
Note that padding bottom value must be greater than sticky button height

Related

How do I make a button shadow adjacent to the edges of the card?

I made a card with rounded corners, but they cut shadows on the buttons when pressed.
Is there any method to handle this?
The buttons are located in the upper right and lower left corners.
But when I launch the app, I got this:
As you can see, the shadow is not adjacent to the edges of the card.
My code:
<?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="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/networks_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="#dimen/card_horizontal_margin"
android:layout_marginVertical="#dimen/card_vertical_margin"
app:cardBackgroundColor="#color/background_secondary"
app:cardCornerRadius="#dimen/card_corner_radius"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/networks_card_content_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/networks_card_content_permanent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="#dimen/card_content_horizontal_margin">
<ImageButton
android:id="#+id/item_card_expand_or_loose_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#color/background_secondary"
android:contentDescription="#string/description_expand_or_loose_card_button"
android:src="#drawable/ic_button_expand"
android:padding="#dimen/card_horizontal_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
...
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/networks_card_hidden_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
...
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_settings"
android:backgroundTint="#color/background_secondary"
app:icon="#drawable/ic_settings"
app:layout_constraintTop_toBottomOf="#id/item_card_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:paddingStart="#dimen/card_horizontal_margin"
android:paddingBottom="#dimen/card_vertical_margin"
style="?android:attr/borderlessButtonStyle" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

i cant click whole cardview

Hello i have a problem with my cardview. when i click whole cardview with binding.root.setonclicklistener{} doesnt work. only work when i click a little part on bottom. but also when i try click imageview (in my cardview) for favorite it works correctly. how can i fix that ?
<androidx.cardview.widget.CardView
android:id="#+id/cv_product_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="#dimen/radius_10dp"
app:cardElevation="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_product_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_bordered_ghost_white_with_radius_10dp_width_1dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_product_item_top_container"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/cl_product_item_bottom_container"
app:layout_constraintDimensionRatio="0.78"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/vp_product_item_images"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/silver"
android:elevation="-1dp"
android:orientation="horizontal" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tl_product_item"
android:layout_width="wrap_content"
android:layout_height="#dimen/size_25"
android:background="#color/white_p0"
app:tabBackground="#drawable/selector_indicator_white_4dp"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabPaddingEnd="#dimen/size_15"
app:tabPaddingStart="#dimen/size_15"
app:tabPaddingTop="0dp"
android:layout_marginBottom="#dimen/margin_25"
android:layout_marginStart="#dimen/margin_50"
app:layout_constraintBottom_toTopOf="#id/cv_product_item_top"
app:layout_constraintStart_toStartOf="#id/vp_product_item_images"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/iv_product_item_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/padding_50"
android:src="#{data.isFavorite ? #drawable/ic_favorite_filled_cerise : #drawable/ic_favorite_empty_lilac_bloom}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="#drawable/ic_favorite_filled_cerise" />
Try this -
Add these 2 attributes in your card view - android:clickable="true" and android:focusable="true"
when i change viewpager height for example 20dp i noticed click is works except the 20dp. viewpager doesnt allow me for click. i tried clickable and focusable false in viewpager but still same :(
<androidx.cardview.widget.CardView
android:id="#+id/cv_product_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="#dimen/radius_10dp"
app:cardElevation="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_product_item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_bordered_ghost_white_with_radius_10dp_width_1dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_product_item_top_container"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/cl_product_item_bottom_container"
app:layout_constraintDimensionRatio="0.78"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/vp_product_item_images"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="#color/silver"
android:elevation="-1dp"
android:orientation="horizontal" />

Unfixed element on top of RecyclerView

I have something like this:
<?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"
android:padding="10dp"
tools:context=".ui.base.core.example">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/topicsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="#layout/item_topics" />
</androidx.constraintlayout.widget.ConstraintLayout>
When I run this, the TextView element is fixed and scrolls when I scroll through my RecyclerView. Is there a way so that I can make it where the TextView element is on top of the RecyclerView and when I scroll it's not fixed? I'm using a TextView to just do testing, but eventually I'd like to have a header on top of the RecyclerView that shouldn't be scrollable with the RecyclerView and just stay on top.
You need to set up constraints.
Approximately like this:
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#id/topicsRecyclerView" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/topicsRecyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView"
app:layout_constraintBottom_toBottomOf="parent" />

Placing horizontal recyclerview at a specific position using ConstraintLayout

I want to place my horizonatl recyclerview at 30% screen width from start
<android.support.constraint.ConstraintLayout 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.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="horizontal"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:background="#android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/guideline" />
<android.support.constraint.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.3" />
</android.support.constraint.ConstraintLayout>
But it is not recyclerview not appearing on screen working any idea how to achieve this.
You never gave your recyclerView a vertical constraint so what happened is that at the run time your recyclerView just jumped to the top of the screen.
When I copied your code I saw this error:
This view is not constrained vertically: at runtime, it will jump to the top unless you add a vertical constraint
Some tip - if you see the red line on your view in the XML/the red warning button from the design you should really look at the error and change your layout accordingly.
And of course, I won't leave you without a good working layout - here is the layout that I made for the recyclerView to start at 30% of the screen, I have checked it and its working. (i was working with androidx but just change it to the support library if you want)
<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">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.3"/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="#+id/guideline2"
app:layout_constraintTop_toTopOf="parent"
android:background="#color/colorPrimaryDark"/>
your RecyclerView is missing the vertical constraints; Add at least one so that the view can be rendered.
constrained to top:
app:layout_constraintTop_toTopOf="parent"
if you want it to use the whole parent, add these too:
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
Remove the ConstraintLayout and use Linearlayout instead, than use the android:weight= property accordingly in both guideline and RecyclerView.
This will work fine for you
<android.support.constraint.ConstraintLayout 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.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="0dp"
android:layout_height="0dp"
android:clipToPadding="false"
android:orientation="horizontal"
android:paddingStart="20dp"
android:paddingEnd="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="#id/guideline"
app:layout_constraintBottom_toBottomOf="parent"
/>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent=".3" />
</android.support.constraint.ConstraintLayout>

Using ListView inside ConstraintLayout

I have read on Android Developers that ConstraintLayout can be used to design a responsive layout for an application. There is a parent ConstraintLayout which houses a toolbar and two other ConstraintLayouts. The first child ConstraintLayout is going to act as empty view for my ListView. The second ConstraintLayout holds my listview and a floating action button. Currently, the the listview appears under the Toolbar, rather than below it. Also as seen in the screenshot, the floating action button appears outside visible area.
See the screenshot below:
And this is the app layout when the list is empty:
This is the code for my layout:
<?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"
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<android.support.constraint.ConstraintLayout
app:layout_constraintTop_toBottomOf="#id/toolbar"
android:id="#+id/empty_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
<TextView
app:layout_constraintTop_toTopOf="parent"
android:id="#+id/tv_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/list_is_empty"
android:textSize="#dimen/large_text"
android:textStyle="bold"
/>
<ImageView
android:id="#+id/iv_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/tv_empty_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:contentDescription="#string/list_is_empty"
android:src="#drawable/emptybox" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/main_area"
android:layout_marginTop="50dp"
android:layout_marginBottom="?actionBarSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/toolbar"
app:layout_constraintBottom_toBottomOf="parent">
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="?attr/actionBarSize"
android:layout_marginLeft="#dimen/margin_side"
android:layout_marginStart="#dimen/margin_side"
android:layout_marginRight="#dimen/margin_side"
android:layout_marginEnd="#dimen/margin_side"
android:layout_marginTop="?attr/actionBarSize"
/>
<android.support.design.widget.FloatingActionButton
android:layout_below="#+id/listview"
android:id="#+id/fab"
android:layout_width="#android:dimen/notification_large_icon_width"
android:layout_height="#android:dimen/notification_large_icon_height"
android:layout_gravity="end|bottom"
android:src="#drawable/plus"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
While using ConstraintLayout you have to add constraints for 'constraintTop',constraintRight,constraintBottom,constraintLeft or constraintStart and constraintEnd. only if you constraint all your four sides the constraint layout (or Constraint Start or End with other References) works well. Otherwise the layout will not work correctly
For Further Reference https://codelabs.developers.google.com/codelabs/constraint-layout/index.html?index=..%2F..%2Findex#0
https://developer.android.com/training/constraint-layout/index.html
There are a couple of things that you can improve with the XML and make the design easier.
First, the main layout will match the screen, to have the preview correctly simulate that, you can set its width/height to match_parent
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
Then, Android Studio should be giving you warnings/errors and saying The view is not constrained horizontally/vertically. In ConstraintLayout, you have to use constraints to specify how your views are placed. If you don't, by default they will position at 0/0 and most probably will look different when it runs on the device:
<ListView
android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="0dp" />
Now, you should be able to that the main_area overlaps with the toolbar. To fix it, you can change main_area height to match the constrains:
android:id="#+id/main_area"
android:layout_height="0dp"
You should be able to obtain a design similar to what you intended.
Here is your desired result, I've made some changes like margins, src just to make it work in my studio, so you'll have to choose whatever you were using, just replace mine with your src's and margins etc...
<?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"
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="0dp"
android:layout_height="56dp"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<android.support.constraint.ConstraintLayout
app:layout_constraintTop_toBottomOf="#+id/toolbar"
android:id="#+id/empty_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<TextView
app:layout_constraintTop_toTopOf="parent"
android:id="#+id/tv_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
android:text="list_is_empty"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
android:id="#+id/iv_empty_view"
android:layout_width="20dp"
android:layout_height="20dp"
app:layout_constraintTop_toBottomOf="#+id/tv_empty_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="#fff222" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/main_area"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<ListView
android:id="#+id/listview"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<android.support.design.widget.FloatingActionButton
android:layout_marginEnd="30dp"
android:layout_marginBottom="30dp"
android:id="#+id/fab"
android:layout_width="64dp"
android:layout_height="64dp"
android:src="#drawable/bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
Here's the output:
I was also facing the same issue.
I made a mistake of keeping layout_width of ListView as fixed width. I changed it to match_constraint and it's coming correctly without any cut.
For height I was facing similar issue so I changed it to match_constraint and it worked.

Categories

Resources