Aug 29 | 3:50 PM |
Mark M. | has entered the room |
Aug 29 | 3:55 PM |
Mark M. | turned on guest access |
marekdef | has entered the room |
Mark M. |
hello, marekdef!
|
Mark M. |
how can I help you today?
|
marekdef |
hi Mark
|
marekdef |
I have an image on the top and the bunch of information below
|
Aug 29 | 4:00 PM |
marekdef |
the number of information is varying
|
marekdef |
so there can be pages that have lot of information
|
marekdef |
and some that have almost none
|
marekdef |
what we would like to have is something like collapsing toolbar with image
|
marekdef |
but for the pages with little information we would like the image to stretch and have no scrolling
|
marekdef |
if I use coordinator I think I need to give the image size
|
Mark M. |
you may wind up having to choose between two different layouts, based on whatever your cutoff is between "normal" and "no scrolling" interfaces
|
Mark M. |
note that I have never implementing a collapsing toolbar, so I don't know much about how that works
|
marekdef |
well I just started with it so maybe we can have that behaviro
|
Aug 29 | 4:05 PM |
Mark M. |
in general, if the UI in Scenario A is significantly different than the UI in Scenario B, trying to implement that using a single layout resource can be nasty
|
marekdef |
yes but I am not sure how can I determine which layout to pick
|
marekdef |
we have title(s), some tags + dynamic number of buttons
|
marekdef |
in theory I could measure them
|
Mark M. |
does each piece of information have titles+tags+buttons? or is the information itself titles+tags+buttons?
|
marekdef |
the latter
|
marekdef |
I said titles but is one title but it can be wrapped to two lines
|
Mark M. |
so, could the algorithm be as simple as "if the combined number of titles, tags, and buttons is less than N, use the no-scrolling UI"?
|
Mark M. |
basically, some human is deciding that there is a no-scrolling UI scenario
|
Mark M. |
that person also has the responsibility of deciding *when* you use the no-scrolling scenario
|
Aug 29 | 4:10 PM |
Mark M. |
perhaps with some negotiation with you and other engineers, to choose something that isn't crazy to implement :-)
|
Mark M. |
for example, while the measuring solution probably could work, that seems like it is more work that should be needed to make this decision
|
marekdef |
I always steer clear of code solutions for UI and look for layout that could work
|
marekdef |
I said no scrolling but this means more no collapsing
|
marekdef |
because with Coordinator + collapsing toolbar I seem to always be able to scroll the content up and collapse toolbar
|
Mark M. |
yeah, unfortunately, since I don't have experience with collapsing toolbars, I do not know much about how to control whether collapsing is an option or not
|
marekdef |
if there is no much information like the title only + button the view looks bit empty
|
Mark M. |
fill the empty space with a picture of a kitten -- everyone loves kittens! :-)
|
marekdef |
yes I want to have the image but on top :)
|
marekdef |
I have implemented some other option
|
Mark M. |
have *two* images! the real one with an extra *bonus* kitten!
|
sudokai | has entered the room |
Aug 29 | 4:15 PM |
marekdef |
so I have image + scroll view
|
sudokai |
Hello Mark
|
marekdef |
scroll view is wrap_content
|
Mark M. |
(hello, sudokai: I will be with you shortly!)
|
marekdef |
is constrained to a guideline somewhere on top + bottom + 1.0 bias (so is at the bottom always)
|
marekdef |
image is parent on top + the scroll
|
marekdef |
on the bottom
|
marekdef |
this works until scroll view exceeds the top constraint
|
marekdef |
and it seems is not holding to that constraint when has wrap content
|
Mark M. |
if you have constraints like that, can the height be 0dp instead of wrap content?
|
marekdef |
I. think then I will have it push the image to be smaller
|
Mark M. |
the guideline is fixed -- 0dp should not move it
|
marekdef |
the image is constrained to the scroll
|
marekdef |
that if scroll is small the image is big
|
marekdef |
the scroll is constrained to the guideline on the top
|
Mark M. |
but then the image could be constrained to that guideline on the bottom
|
Aug 29 | 4:20 PM |
marekdef |
I don't have one, but I wanted the image to take the space this scroll cannot take
|
Mark M. |
oh, yeah, OK, that's going to be a challenge
|
marekdef |
OK
|
Mark M. |
off the top of my head, I am not certain how you are going to be able to pull that off, though I certainly cannot rule out there being a solution
|
Mark M. |
let me take a question from sudokai, and I will come back to you in a little bit
|
marekdef |
sure!
|
Mark M. |
sudokai: your turn! how can I help you today?
|
Mark M. |
sudokai: do you have a question?
|
Aug 29 | 4:25 PM |
Mark M. |
sudokai: if you come up with a question, chime in!
|
Mark M. |
in the meantime...
|
Mark M. |
marekdef: back to you!
|
marekdef |
I am wondering, if I have wrap_content + constraints, it seems if the view grows too much it does not respect the constraints
|
marekdef |
constraints = top + bottom
|
Mark M. |
that may be more of a ScrollView thing -- have you tried NestedScrollView?
|
marekdef |
actually I have NestedScrollView
|
Mark M. |
ah
|
Mark M. |
usually, with either of those, wrap_content for the height is the wrong answer
|
Mark M. |
you want to say "this is the space in which you can scroll", which implies a fixed height or fixed top/bottom anchores
|
Mark M. |
er, anchors
|
Aug 29 | 4:30 PM |
Mark M. |
instead of a top constraint, have you tried playing with wrap_content for the height, but also defining android:maxHeight?
|
Aug 29 | 4:30 PM |
Mark M. |
you aren't going to be able to set that dynamically in the layout (unless perhaps you are using data binding), but it may be worth an experiment to see if NestedScrollView behaves more as you would like with that setup
|
marekdef |
android:maxHeight -> I used constrain version
|
marekdef |
app:layout_constraintHeight_max
|
marekdef |
this work almost :)
|
Mark M. |
oh, right, the framework only has minHeight
|
marekdef |
I think there is maxheight as well
|
Mark M. |
not on View, at least according to the docs
|
marekdef |
allright
|
marekdef |
this works but I would prefer to be constraining to the guideline
|
marekdef |
because with wrap + 1.0 bias this info component is measured from the bottom
|
marekdef |
so I give max height like 480dp it does not exactly hit the guideline
|
Mark M. |
does that matter, though? your objective seems to be: have the actual NestedScrollView height be the maximum of the height of its content or a fixed value
|
Aug 29 | 4:35 PM |
Mark M. |
does it matter whether that fixed value comes from a guideline?
|
marekdef |
well the spec specifies the minimum header size
|
marekdef |
so that is from the top
|
Mark M. |
I guess that I do not understand how that impacts setting the max height of the NestedScrollView
|
marekdef |
does not impact it and is hard to match them
|
Mark M. |
¯\_(ツ)_/¯
|
marekdef |
if I place the guideline at 200dp from the top
|
marekdef |
and the info is 480dp layout_constraintHeight_max
|
marekdef |
it works only on 680dp height I think
|
Aug 29 | 4:40 PM |
sudokai | has left the room |
Mark M. |
I thought that your image was tied to the top of the NestedScrollView, though, not a guideline
|
marekdef |
yes
|
Mark M. |
so, what is the guideline for?
|
Mark M. |
(in this scenario, where you are using layout_constraintHeight_max)
|
marekdef |
yes in that scenario is
|
marekdef |
the guidelin is for the top of nested scroll view
|
marekdef |
or maybe it does not matter so much because this constraint apparently is not used
|
marekdef |
I would like it to be used
|
Mark M. |
I am pretty much out of ideas at this point -- it is the sort of thing I would need to be playing around with layouts and stuff directly
|
marekdef |
yes I understand
|
Aug 29 | 4:45 PM |
marekdef |
is there a way to make scroll view don't stretch my layout if is getting big
|
Mark M. |
well, normally, a ScrollView/NestedScrollView does not stretch in the first place
|
Mark M. |
normally, we give it a fixed height or fixed top/bottom anchors, so it knows its area to scroll inside
|
Mark M. |
so, for example, as we discussed, if you use your guideline as the top anchor for the NestedScrollView, and you set the height to 0dp, the NestedScrollView should behave just fine... but you will not be able to have your ImageView "absorb" any excess space not needed by the NestedScrollView's contents
|
Aug 29 | 4:50 PM |
Mark M. |
that is why I was hoping that the max-height approach would be enough for your needs, as that is the only way that I can see where you can use wrap_content for the NestedScrollView (so you can have the ImageView take extra space when available) yet cap the height of the NestedScrollView (so it actually starts scrolling)
|
Mark M. |
the only other idea I have is if you can write a custom RecyclerView LayoutManager that can implement your rules, and everything (ImageView and information) winds up in the RecyclerView
|
Mark M. |
but I have never written a LayoutManager, let alone one like that
|
Aug 29 | 4:55 PM |
marekdef |
ok thank you
|
Mark M. |
sorry that I did not have a better solution!
|
Aug 29 | 5:00 PM |
marekdef |
no problem at all
|
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
and the next chat is Tuesday at 7:30pm US Eastern
|
Mark M. |
have a pleasant day!
|
marekdef | has left the room |
Mark M. | turned off guest access |