Office Hours — Today, February 6

Thursday, February 4

Feb 6
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:20 PM
jason a.
has entered the room
Mark M.
hello, Jason!
how can I help you today?
jason a.
View paste
Hello, Mark!
First off, thank you for writing the Commonsware books — I used them a decade ago when first learning about Android, and am using them now for my job, and REALLY appreciate how detailed and clear the Kotlin book is. :)
Mark M.
thanks for the kind words! I am glad that you like them!
jason a.
I'm trying to figure out a few issues with a BottomSheetBehavior and fitsSystemWindows — essentially, my layouts keep getting extra arbitrary padding added to them.
4:25 PM
Mark M.
I have not worked with fitsSystemWindows personally in a couple of years, so I do not believe I will be much help with that
jason a.
Ah, ok. Any gotchas or places to look that you can suggest if you see layouts adding arbitrary (62dp ... 49dp) padding to the top and bottom?
I've run through several blogposts and am still wrapping my brain around it.
Mark M.
yeah, this is one of those "Android got waaaaaaaaaaaaaay too complicated" areas IMHO
jason a.
hahahaha, ok 😅
Mark M.
what is inflating the layout resource that is winding up with the extra padding?
jason a.
View paste
main activity (CoordinatorLayout) [1]
  includes bottomsheet layout (LinearLayout with BottomSheetBehavior) [2]
    has a NestedScrollView (or FrameLayout, in other tests) [3]
       into which a fragment is inflated [4]

both [2] and [3] have been getting extra padding, but [1] and [4] have not
4:30 PM
Mark M.
and you concluded from testing that it is BottomSheetBehavior that is triggering the extra padding? IOW, if you remove that, the padding vanishes?
jason a.
Aside: I have an easier question for you if you'd like :) ...what's the best way to increase the hit area size on an ImageButton? I've seen setting up a transparent view behind or above; wrapping the button in a view and listening to clicks on the view group; and something about TouchDelegate ...is there a best practice?
I will try removing the BottomSheetBehavior and test, thank you!
Mark M.
I have used the TouchDelegate approach
jason a.
(thank you!)
4:35 PM
Mark M.
View paste (2 more lines)
        fun setExpandedTouchArea(view: View, extra: Float) {
            val parent = view.parent as View
            val extraSpace = extra.roundToInt()

            parent.doOnLayout {
                val touchArea = Rect()

                view.getHitRect(touchArea)

                touchArea.top -= extraSpace
                touchArea.bottom += extraSpace
                touchArea.left -= extraSpace
                touchArea.right += extraSpace

                parent.touchDelegate = TouchDelegate(touchArea, view)
...
that adds extra pixels to all four sides of whatever the view is
jason a.
Thank you, Mark, that's exactly what I was looking to do.
4:40 PM
jason a.
It looks like it will take me a little longer to disentangle the BottomSheetBehavior (I'm making updates to a legacy app), but thank you again for the office hours and have a good weekend!
Mark M.
good luck! :-)
5:00 PM
jason a.
has left the room
Mark M.
turned off guest access

Thursday, February 4

 

Office Hours

People in this transcript

  • jason a.
  • Mark Murphy