9

I'm making an app with list of icons, so like two icons per row, I have 8 icons. 4 fit into the view, but the reset doesn't. I've used ConstraintLayout (latest Android Studio).

So, I thought - how do I achieve this ConstraintLayout-positioning and make it scrollable? I've added ScrollView. When it is created, it automatically adds LinearLayout under. So no problem, I remove it, I add ConstraintLayout in it, so that my project looks like this:

ConstraintLayout - ScrollView -- ConstraintLayout

So far so good, but now if I drop any widgets on the Design view or Blueprint view - nothing is added. If I drop it under 2nd constraint layout, it adds up alright, but constraints are built against 1st constraintlayout, and if I switch to 2nd, all constraintlayout controls disappear from top of the design view.

My question is this: how do I make scrollable icon page, positioning it properly (preferably the constraint layout way)?

Thanks!

12
  • Just use LinearLayout as a child to ScrollView. It will place your view further and further down if you need, and you'll be able to scroll. Commented Jan 20, 2017 at 9:28
  • @Ekalips, then layout gets Linear (and broken). The idea was to do layout the constraintlayout way, so that I have: row 1 image, caption under it; image caption under it; row 2 image caption under it; image, caption under it. If I do it like you said, it turns to LinearLayout and gets aligned according to the rules of Linear layout, eg. no defined margins and stuff, like with constraintlayout. Commented Jan 20, 2017 at 9:47
  • you need to specify orientation (vertical in your case) and use some child views. Something like <RelativeLayout><ImageView/><TextView/></RelativeLayout> and repeat this few times inside LinearLayout. But also I recomend you to use some ListView (even RecyclerView) Commented Jan 20, 2017 at 10:21
  • @Ekalips It works and it doesn't. Stack Linear->ScrollView->Linear->Relative - first of all, objects are not properly aligned, the way they would be with ConstraintLayout. Second, scroll doesn't work anymore. ListView - doesn't seems to be what I want - I need picture and caption under it, two per per row. Commented Jan 20, 2017 at 11:05
  • Tried making something similar with PhoneGap/Framework 7 - much easier to design, but a) performance naturally less than native app, and b) no inertia/momentum touch-pull animation :( Commented Jan 20, 2017 at 11:06

1 Answer 1

1

I believe this can be marked as a duplicate (I don't think I have the points to mark it so) of the following: android Is it possible to put a constraint layout inside a ScrollView

To answer your question, it is not possible currently (as of 10/31/2017) because there is a bug in Android Studio v3.0.0

Check out this image, you can see the ScrollView doesn't act as it should: ScrollView malfunctions with ConstraintLayout

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.