I have a layout that looks something like this:
<?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:id="#+id/main_read_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.project.books.flipview.FlipView
android:id="#+id/flip_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/color_black"
app:orientation="horizontal"
tools:context=".ReadActivity" >
</com.project.books.flipview.FlipView>
<include
android:id="#+id/readingtoolbar"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
layout="#layout/readingbar_layout" />
</android.support.constraint.ConstraintLayout>
The FlipView is a custom Framelayout that has a page turn animation like a book. The user is also able to pinch zoom on each page spread.
The Toolbar below has a selection of crayons. Once a user clicks on a color, an invisible fragment is launched and the user is able to draw on top of the page spread.
This is the toolbar Layout
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/readbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#color/defaultdark_color"
app:layout_constraintBottom_toBottomOf="parent"
android:elevation="4dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/tabtools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="#drawable/icontools"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/tabdictionary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginStart="16dp"
android:src="#drawable/icondictionary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/tabtools"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/tabassessment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:alpha="0.3"
android:scaleType="fitXY"
android:src="#drawable/iconassesment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/tabdictionary"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/tabexit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:scaleType="fitXY"
android:src="#drawable/iconclose"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/eraser"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:src="#drawable/drawingeraser"
android:scaleType="fitXY"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="#id/guide_eraser"
app:layout_constraintBottom_toBottomOf="parent" />
<ImageView
android:id="#+id/crayon_black"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingblack"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_blue"
app:layout_constraintStart_toEndOf="#+id/guide_eraser" />
<ImageView
android:id="#+id/crayon_blue"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingblue"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_green"
app:layout_constraintStart_toEndOf="#+id/crayon_black" />
<ImageView
android:id="#+id/crayon_green"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawinggreen"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_orange"
app:layout_constraintStart_toEndOf="#+id/crayon_blue" />
<ImageView
android:id="#+id/crayon_orange"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingorange"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_pink"
app:layout_constraintStart_toEndOf="#+id/crayon_green" />
<ImageView
android:id="#+id/crayon_pink"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingpink"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_red"
app:layout_constraintStart_toEndOf="#+id/crayon_orange" />
<ImageView
android:id="#+id/crayon_red"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingred"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_violet"
app:layout_constraintStart_toEndOf="#+id/crayon_pink" />
<ImageView
android:id="#+id/crayon_violet"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingviolet"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_white"
app:layout_constraintStart_toEndOf="#+id/crayon_red" />
<ImageView
android:id="#+id/crayon_white"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:src="#drawable/drawingwhite"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/crayon_yellow"
app:layout_constraintStart_toEndOf="#+id/crayon_violet" />
<ImageView
android:id="#+id/crayon_yellow"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:onClick="buttonClicked"
android:scaleType="fitXY"
android:visibility="gone"
android:layout_marginTop="4dp"
android:src="#drawable/drawingyellow"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/crayon_white"
app:layout_constraintEnd_toStartOf="#id/guide_center"/>
<ImageView
android:id="#+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/iconreset"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/guide_center"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:visibility="gone"
android:actionProviderClass="android.widget.ShareActionProvider"
android:showAsAction="ifRoom"
android:src="#drawable/iconshare"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/tabexit2"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/tabexit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:visibility="gone"
android:src="#drawable/iconclose"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="#+id/guide_eraser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.1"/>
<android.support.constraint.Guideline
android:id="#+id/guide_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.6"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
The toolbar initially starts out as invisible. If you click anywhere on the page, it should slide out from the bottom. I am able to capture the click event by using the dispatchTouchEvent
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
if (ev!!.action == MotionEvent.ACTION_DOWN) {
startX = ev.x
startY = ev.y
}
if (ev.action == MotionEvent.ACTION_UP){
val endX = ev.x
val endY = ev.y
if (isAClick(startX, endX, startY, endY)) {
onSlideViewButtonClick(reading_toolbar!!)
return true
} else {
return super.dispatchTouchEvent(ev)
}
}
return super.dispatchTouchEvent(ev)
}
So the toolbar slides out but if I click on any crayon on the toolbar, it slides back down which it isn't supposed to do. Basically, what I want is that if the user clicks anywhere else EXCEPT on the toolbar itself, then it should slide back down.
I tried using onTouch so I can pass the view instead of dispatchTouchEvent but I can't seem to capture clicks even with the same logic. I can capture a drag event, though.
class ReadActivity : Activity(), FlipViewAdapter.Callback, FlipView.OnFlipListener, FlipView.OnOverFlipListener, View.OnTouchListener {
...
}
setting
flip_view.setOnTouchListener(this)
testing the click here
override fun onTouch(v: View?, ev: MotionEvent?): Boolean {
println("clicking")
// put actual clicking logic
return true
}
Related
I am currently trying to expand a view when it is focused and contract it when unfocused. But, I am unable to get the events for onFocusChangeListener. I tried adding that for all of the views inside the parent view but that didn't work either. Is there anything like reyclerview takes all the focus changes to itself not allowing its children? This is my item code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginBottom="20dp"
app:cardCornerRadius="6dp"
app:cardElevation="3dp">
<LinearLayout
android:id="#+id/selected"
android:layout_width="7dp"
android:layout_height="match_parent"
android:background="#167ED1"
android:orientation="horizontal" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/largeItemView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#color/primary"
android:alpha="0.5"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="#+id/questionTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="Question"
android:maxLines="1"
android:padding="20dp"
android:theme="#style/SelectedColorBlue"
app:layout_constraintEnd_toStartOf="#+id/settings"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:focusable="true"
android:focusableInTouchMode="true"/>
<ImageView
android:id="#+id/settings"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_marginHorizontal="10dp"
android:background="?selectableItemBackgroundBorderless"
android:src="#drawable/more_vert"
app:layout_constraintBottom_toBottomOf="#id/questionTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#id/questionTitle"
app:tint="#color/white" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/optionsRV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:padding="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="#id/addOption"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/questionTitle"
tools:itemCount="2"
tools:listitem="#layout/add_form_option_item" />
<TextView
android:id="#+id/points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="1 Point"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#id/addOption"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#id/addOption" />
<TextView
android:id="#+id/editPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="#string/editHtmlUnderline"
android:textColor="#color/primary"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/points"
app:layout_constraintStart_toEndOf="#+id/points"
app:layout_constraintTop_toTopOf="#+id/points" />
<Button
android:id="#+id/addOption"
android:layout_width="wrap_content"
android:layout_height="57dp"
android:layout_margin="20dp"
android:drawableEnd="#drawable/plus"
android:text="Add Option"
app:cornerRadius="18dp"
app:layout_constraintBottom_toTopOf="#id/required"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="#+id/delete"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="10dp"
android:padding="3dp"
android:src="#drawable/delete"
app:layout_constraintBottom_toBottomOf="#+id/required"
app:layout_constraintEnd_toStartOf="#+id/imageView"
app:layout_constraintTop_toTopOf="#+id/required"
app:tint="#color/gray" />
<ImageView
android:id="#+id/imageView"
android:layout_width="1dp"
android:layout_height="35dp"
android:layout_marginHorizontal="10dp"
android:padding="3dp"
android:src="#color/gray"
app:layout_constraintBottom_toBottomOf="#+id/required"
app:layout_constraintEnd_toStartOf="#id/required"
app:layout_constraintTop_toTopOf="#+id/required"
app:tint="#color/gray" />
<CheckBox
android:id="#+id/required"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:buttonTint="#color/primary"
android:checked="true"
android:text="Required"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="#+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="addOption,points,editPoints,delete,imageView,required" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
and this is my code for adding the focus listsner inside the onBIndViewHolder:
binding.largeItemView.setOnFocusChangeListener { _: View, hasFocus: Boolean ->
Toast.makeText(itemView.context,"Focus change $hasFocus", Toast.LENGTH_SHORT).show()
binding.selected.visibility = if(hasFocus) VISIBLE else View.GONE
binding.group.visibility = if(hasFocus) VISIBLE else View.GONE
}
binding.largeItemView.children.forEach {
it.setOnFocusChangeListener { _, hasFocus ->
Toast.makeText(itemView.context,"Focus change $hasFocus", Toast.LENGTH_SHORT).show()
binding.selected.visibility = if(hasFocus) VISIBLE else View.GONE
binding.group.visibility = if(hasFocus) VISIBLE else View.GONE
}
}
and this is my reycler view:
<ScrollView>
<NestedScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/optionsRV"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingHorizontal="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="10"
tools:listitem="#layout/item_question_add_item" />
</NestedScrollView>
</ScrollView>
Thanks in advance
I have problem with Google Maps V3. Basically I have application with HomeActivity (AppCompatActivity). In this activity I have HomeFragment (inherits from Fragment) and now what I want is to have SupportMapFragment from Google Maps library, so inside HomeFragment layout I put
<fragment
android:id="#+id/map"
android:name="com.google.android.libraries.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
In HomeFragment onCreateView callback I have
mapFragment = childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment?.getMapAsync(this)
Map is showing, but the problem is I can't do anything - I mean I can't scroll or zoom this map, it is not responding.
I tried to put MapView instead of whole fragment and map was reacting to gestures. But this solution isn't perfect - for example isMyLocationEnabled doesn't show current location icon and click on button in right upper corner is not moving camera to location (yet callback is called).
Any idea how I can solve this one?
EDIT: Layout code
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="homeVM"
type="viewmodel.home.map.HomeViewModel" />
<variable
name="detailVM"
type="viewmodel.home.map.SheetDetailViewModel" />
<variable
name="shareVM"
type="viewmodel.home.map.HomeSheetShareViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.libraries.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="#+id/sidebarBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dp"
android:foreground="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.openSidebar()}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:background="#drawable/white_bg_rounded"
android:padding="10dp"
android:tint="#color/warm_grey"
android:src="#drawable/ic_menu_warm_gray_24dp" />
</FrameLayout>
<LinearLayout
android:id="#+id/mapOptionsMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="72dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:animateLayoutChanges="true"
android:background="#drawable/white_bg_rounded"
android:divider="#drawable/line_background_margin_8"
android:orientation="vertical"
android:showDividers="middle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/mapTypeBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.mapType()}"
android:padding="10dp"
android:src="#drawable/ic_layers_warm_gray_24dp"
app:tint="#color/warm_grey" />
<ImageView
android:id="#+id/arBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.onArClick()}"
android:padding="10dp"
android:src="#drawable/ic_ar_warm_grey_24dp"
app:tint="#color/warm_grey" />
<ImageView
android:id="#+id/myTrackerLocationBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.myTrackerLocation()}"
android:padding="10dp"
android:scaleType="fitXY"
android:src="#drawable/ic_navigation_on_warm_gray_24dp"
app:tint="#color/warm_grey" />
<ImageView
android:id="#+id/myLocationBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.myLocation()}"
android:padding="8dp"
android:src="#drawable/ic_navigation_on_warm_gray_24dp"
app:tint="#color/warm_grey" />
</LinearLayout>
<LinearLayout
android:id="#+id/trackerOptionsMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:animateLayoutChanges="true"
android:background="#drawable/white_bg_rounded"
android:divider="#drawable/line_background_margin_8"
android:orientation="vertical"
android:showDividers="middle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mapOptionsMenu">
<view.AnimatedRefreshImageView
android:id="#+id/refreshBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="#{(v) -> homeVM.refresh(shareVM.items)}"
app:layout_constraintBottom_toTopOf="#+id/myLocationBtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/myTrackerLocationBtn"/>
<ImageView
android:id="#+id/supertracking_btn"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:onClick="#{(v) -> homeVM.superTracking(shareVM.selected.id)}"
android:padding="10dp"
android:src="#drawable/drawable_superlive" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/trackersSheet"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<activity.home.home.fragments.sheet.TrackersSheet
android:id="#+id/list_sheet"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
bind:items="#{shareVM.items}"
bind:visible="#{shareVM.selected == null}"/>
<activity.home.home.fragments.sheet.DetailSheet
android:id="#+id/detail_sheet"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
bind:isAutoSelect="#{shareVM.isAutoSelect}"
bind:setAutoSelectTracker="#{shareVM.items[0]}"
bind:tracker="#{shareVM.selected}"
bind:viewModel="#{detailVM}"
bind:visible="#{shareVM.selected != null || shareVM.isAutoSelect}">
</activity.home.home.fragments.sheet.DetailSheet>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.github.stkent.amplify.prompt.DefaultLayoutPromptView
android:id="#+id/prompt_view"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:prompt_view_background_color="#color/blood_orange"
app:prompt_view_button_corner_radius="15dp"
app:prompt_view_critical_feedback_question_negative_button_label="#string/prompt_view_feedback_negative"
app:prompt_view_critical_feedback_question_positive_button_label="#string/prompt_view_feedback_positive"
app:prompt_view_critical_feedback_question_title="#string/prompt_view_feedback_question_title"
app:prompt_view_positive_feedback_question_negative_button_label="#string/prompt_view_rate_negative"
app:prompt_view_positive_feedback_question_positive_button_label="#string/prompt_view_rate_positive"
app:prompt_view_positive_feedback_question_title="#string/prompt_view_rate_title"
app:prompt_view_thanks_display_time_ms="2000"
app:prompt_view_user_opinion_question_negative_button_label="#string/general_no"
app:prompt_view_user_opinion_question_positive_button_label="#string/general_yes"
app:prompt_view_user_opinion_question_title="#string/prompt_view_question_title" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/productRating"
android:layout_width="match_parent"
android:layout_height="170dp"
android:background="#color/blood_orange"
android:visibility="#{homeVM.productRatingVisibility}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<TextView
android:id="#+id/productRatingTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="#string/product_rating_popup_title"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/productRatingMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="#string/product_rating_popup_message"
android:textColor="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/productRatingTitle" />
<Button
android:id="#+id/productRatingNoBtn"
style="#style/Button.Rounded.Orange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="#string/product_rating_nothanks_btn"
android:onClick="#{(v) -> homeVM.postponeRating()}"
app:layout_constraintEnd_toStartOf="#+id/guideline9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/productRatingMsg" />
<Button
android:id="#+id/productRatingYesBtn"
style="#style/Button.Rounded.White"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="#string/product_rating_answer_btn"
android:onClick="#{(v) -> homeVM.answerRating()}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline9"
app:layout_constraintTop_toBottomOf="#+id/productRatingMsg" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Ok, I figured it out. Finally. It wasn't Google Maps SDK issue, but something in code. We got this project in late state of development from other company and I wasn't aware of this.
It was all about this piece of code:
if (view is ViewGroup && !isHomeFragment()) {
view.hideSoftKeyboardOnTouchOutside()
}
fun ViewGroup.hideSoftKeyboardOnTouchOutside() {
this.childrenRecursiveSequence()
.filter { it !is EditText }
.forEach {
it.setOnTouchListener { view, _ ->
view.hideSoftKeyboard()
false
}
}
}
It was executed in base fragment onViewCreated callback on inheriting fragment view. Somehow it didn't affect MapBox map reaction to gestures unlike Google map, which was quite useless in that case.
I want to make 2 animations, I have one view that will disappear once its touched(the one with emojis and "How do you feel today?"), with an alpha animation(from 1 to 0 alpha, at the end its visibility will be View.GONE), and then all the other views in the layout should slide up instead of them going up instantly. I have already done the alpha animation, the transition one is the one I can't achieve.
I am using Constraint Layout so what happens is as soon as the first view disappears changing its visibility to GONE, the others move instantly up. I have tried many ways, but I can´t find how to achieve this. I don't know what type of transition or animation should I use.
This is the code I am using fot the alpha animation:
fun hideEmojiView(view: View) {
val fadeOut: Animation = AlphaAnimation(1f, 0f)
fadeOut.interpolator = AccelerateInterpolator()
fadeOut.duration = 500
fadeOut.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationEnd(animation: Animation) {
view.visibility = View.GONE
}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationStart(animation: Animation) {}
})
view.startAnimation(fadeOut)
}
UPDATE: SOLUTION
I ended up making the suggestion #Tenfour04 made. The problem was that I was adding android:animateLayoutChanges="true" to a ScrollView and it needs to be added to a ConstraintLayout, and it needs to be the direct parent of the view you are dissapearing. So here is my Layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:context=".fragments.maincontent.TodayFragment">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:fontFamily="#font/subtitle_font"
android:text="Upcoming"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rv_daily_picks" />
<FrameLayout
android:id="#+id/frameLayout7"
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/textView6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/textView6">
</FrameLayout>
<FrameLayout
android:id="#+id/frameLayout6"
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/textView5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/textView5">
</FrameLayout>
<TextView
android:id="#+id/tv_welcome"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:fontFamily="#font/title_font"
android:text="Welcome, Sebastián"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:fontFamily="#font/subtitle_font"
android:text="Stories"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/emoji_view" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_stories"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView5">
</androidx.recyclerview.widget.RecyclerView>
<FrameLayout
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/textView7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView7"
app:layout_constraintTop_toTopOf="#+id/textView7">
</FrameLayout>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:fontFamily="#font/subtitle_font"
android:text="Daily picks"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rv_stories" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_daily_picks"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6">
</androidx.recyclerview.widget.RecyclerView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_upcoming"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
<ImageView
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/rv_upcoming" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/emoji_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:background="#drawable/round_white_30alpha_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_welcome">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/subtitle_font"
android:text="How do you feel today?"
android:textColor="#color/white"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView13">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/emoji1"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/circle_white"
android:text="😡"
android:textAllCaps="false"
android:textSize="26sp" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/emoji2"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/circle_white"
android:text="🙁"
android:textAllCaps="false"
android:textSize="26sp" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/emoji3"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/circle_white"
android:text="🤢"
android:textAllCaps="false"
android:textSize="26sp" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/emoji4"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/circle_white"
android:text="😃"
android:textAllCaps="false"
android:textSize="26sp" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/emoji5"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/circle_white"
android:text="🤩"
android:textAllCaps="false"
android:textSize="26sp" />
</FrameLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
and my code:
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val binding = FragmentTodayBinding.inflate(layoutInflater)
val user = AppController.get<UserModel>(UserModel.key)
binding.tvWelcome.text = "Welcome, " + user!!.name
binding.emoji1.setOnClickListener{ binding.emojiView.visibility = View.GONE }
binding.emoji2.setOnClickListener{ binding.emojiView.visibility = View.GONE }
binding.emoji3.setOnClickListener{ binding.emojiView.visibility = View.GONE }
binding.emoji4.setOnClickListener{ binding.emojiView.visibility = View.GONE }
binding.emoji5.setOnClickListener{ binding.emojiView.visibility = View.GONE }
return binding.root
}
I need to show() the extended FAB and hide() it based on a boolean. I'm using it in a bottom sheet that extends BottomSheetDialogFragment. Problem is that it works when the bottom sheet is in expanded state, but not in the state in which the sheet opens by default. I also observe a strange behavior - the FAB shows by default when the sheet opens, for a fleeting second and disappears. I'm not sure what's causing this behavior. I tried hiding the FAB by default, but it does not work.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_gravity="top"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context=".ui.attendance.employee.selection.EmployeeSelectionBottomSheet">
<TextView
android:id="#+id/copy_to_emp_title"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:paddingBottom="16dp"
android:text="#string/copy_to"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:background="#color/palegrey"
android:id="#+id/copy_to_emp_search_cc"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_title"
tools:visibility="visible">
<com.google.android.material.textfield.TextInputLayout
style="#style/TextInputLayoutAppearance"
android:hint="#string/enter_chip_txt"
android:id="#+id/copy_to_emp_search_til"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<HorizontalScrollView
android:id="#+id/copy_to_emp_hsv"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scrollbars="none">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="503dp">
<com.google.android.material.chip.ChipGroup
android:id="#+id/copy_to_emp_cg"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="#+id/copy_to_emp_et"
app:layout_constraintEnd_toStartOf="#+id/copy_to_emp_et"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/copy_to_emp_et" />
<com.google.android.material.textfield.TextInputEditText
android:hint="#string/enter_chip_txt"
android:id="#+id/copy_to_emp_et"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/copy_to_emp_cg"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</HorizontalScrollView>
</com.google.android.material.textfield.TextInputLayout>
<TextView
style="#style/Body14Left4SemiBold"
android:id="#+id/copy_to_emp_filter"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="#string/filter"
app:layout_constraintBottom_toBottomOf="#+id/copy_to_emp_filter_icon"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toTopOf="#+id/copy_to_emp_filter_icon" />
<ImageView
android:id="#+id/copy_to_emp_filter_icon"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:padding="3dp"
android:src="#{isFilterViewExpanded?#drawable/ic_arrow_up:#drawable/ic_arrow_down}"
app:layout_constraintEnd_toEndOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_search_til"
tools:src="#drawable/ic_arrow_down" />
<TextView
style="#style/Body14Left2Regular"
android:id="#+id/copy_to_emp_category_label"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="#string/category"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_filter" />
<TextView
style="#style/Body14Left2Regular"
android:background="#drawable/rounded_rect_white_5"
android:id="#+id/copy_to_emp_category"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:layout_width="0dp"
android:padding="8dp"
android:text="#string/select_your_filter_category"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_category_label" />
<TextView
style="#style/Body14Left2Regular"
android:id="#+id/copy_to_emp_sub_category_label"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="#string/sub_category"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_category" />
<TextView
style="#style/Body14Left2Regular"
android:background="#drawable/rounded_rect_white_5"
android:id="#+id/copy_to_emp_sub_category"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:layout_width="0dp"
android:padding="8dp"
android:text="#string/select_your_filter_sub_category"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_sub_category_label" />
<com.google.android.material.button.MaterialButton
android:id="#+id/copy_to_add_filter_btn"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="Add Filter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_sub_category" />
<androidx.constraintlayout.widget.Group
android:id="#+id/copy_to_emp_group"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="#{isFilterViewExpanded?View.VISIBLE:View.GONE}"
app:constraint_referenced_ids="copy_to_emp_sub_category,copy_to_emp_sub_category_label,copy_to_emp_category,copy_to_emp_category_label, copy_to_add_filter_btn"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.chip.ChipGroup
android:id="#+id/copy_to_selected_filter_cg"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_search_cc" />
<TextView
android:id="#+id/copy_to_emp_count_tv"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_width="wrap_content"
android:text="All Employee (264)"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/copy_to_selected_filter_cg" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/copy_to_rv"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:minHeight="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_count_tv" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:backgroundTint="#color/blueberry"
android:id="#+id/copy_to_apply_changes_btn"
android:layout_gravity="bottom|center_horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_width="wrap_content"
android:text="Apply changes"
android:textColor="#color/whitetwo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
change ExtendedFloatingActionButton to FloatingActionButton
Add
<com.google.android.material.circularreveal.CircularRevealFrameLayout
/>
</com.google.android.material.circularreveal.CircularRevealFrameLayout>
fab.setOnClickListener {
fab.isExpanded = !fab.isExpanded
}
thats it
I have views hierarchy like this:
and here is my xml:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/constraintLayout_profile">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" android:id="#+id/swipeRefreshLayout_userControl">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#android:color/white"
android:id="#+id/scrollView_user_control"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView_profile_image_user_information"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/user"
app:civ_border_width="0.5dp"
app:civ_border_color="#FF000000" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp" app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:text="User Fullname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView_user_fullname_user_information" android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/imageView_profile_image_user_information"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:textSize="18sp"/>
<TextView
android:text="user#email.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView_user_email_user_information" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView_user_fullname_user_information"
android:layout_marginTop="8dp"/>
<TextView
android:text="AKAN DIHADIRI"
android:layout_width="0dp"
android:layout_height="35dp"
android:id="#+id/textView_will_come_user_information" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/textView_user_email_user_information"
android:gravity="center|left"
android:paddingStart="16dp" android:background="#D2D1D6"/>
<ImageView
android:src="#drawable/ic_settings"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/imageView_gear_setting_user_information"
app:layout_constraintTop_toTopOf="#+id/imageView_profile_image_user_information"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="24dp"/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="#+id/textView_will_come_user_information"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:listitem="#layout/item_general_event"
android:id="#+id/recyclerView_attended_event_user_control"
app:layout_constraintHorizontal_bias="1.0"
android:nestedScrollingEnabled="false">
</androidx.recyclerview.widget.RecyclerView>
<ImageView
android:id="#+id/imageView_verified_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
app:layout_constraintEnd_toEndOf="#+id/imageView_profile_image_user_information"
app:layout_constraintTop_toTopOf="#+id/imageView_profile_image_user_information"
app:srcCompat="#drawable/verifiedicon" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<ProgressBar
android:id="#+id/progressBar_user_control"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
as you can see, there is recycler view inside my scroll view, and also there is a swipe refresh layout wrap it all.
I want my progress bar will always be in the center of the screen. I have tried to read from here: How to make a ProgressBar stay in the center of screen despite scrolling . it is said that
You need the ScrollView to be at same level as ProgressDialog in your
Layout
I have tried to implement that, like the image above, but I don't know why my progress bar will not appear in the screen.
if I put the progress bar inside the scroll view like this:
the progress bar will appear, but not in the center of the screen. it depends of the number of items inside my recycler view. so how to solve this ?
Place your ProgressBar at the bottom of outer ConstraintLayout. Check below:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/constraintLayout_profile">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" android:id="#+id/swipeRefreshLayout_userControl">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#android:color/white"
android:id="#+id/scrollView_user_control"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView_profile_image_user_information"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/user"
app:civ_border_width="0.5dp"
app:civ_border_color="#FF000000" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp" app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:text="User Fullname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView_user_fullname_user_information" android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/imageView_profile_image_user_information"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:textSize="18sp"/>
<TextView
android:text="user#email.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView_user_email_user_information" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView_user_fullname_user_information"
android:layout_marginTop="8dp"/>
<TextView
android:text="AKAN DIHADIRI"
android:layout_width="0dp"
android:layout_height="35dp"
android:id="#+id/textView_will_come_user_information" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/textView_user_email_user_information"
android:gravity="center|left"
android:paddingStart="16dp" android:background="#D2D1D6"/>
<ImageView
android:src="#drawable/ic_settings"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/imageView_gear_setting_user_information"
app:layout_constraintTop_toTopOf="#+id/imageView_profile_image_user_information"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="24dp"/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="#+id/textView_will_come_user_information"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:listitem="#layout/item_general_event"
android:id="#+id/recyclerView_attended_event_user_control"
app:layout_constraintHorizontal_bias="1.0"
android:nestedScrollingEnabled="false">
</androidx.recyclerview.widget.RecyclerView>
<ImageView
android:id="#+id/imageView_verified_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
app:layout_constraintEnd_toEndOf="#+id/imageView_profile_image_user_information"
app:layout_constraintTop_toTopOf="#+id/imageView_profile_image_user_information"
app:srcCompat="#drawable/verifiedicon" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<ProgressBar
android:id="#+id/progressBar_user_control"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>