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!

Svyatoslav
  • 121
  • 1
  • 5
  • 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. –  Ekalips Jan 20 '17 at 09: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. – Svyatoslav Jan 20 '17 at 09:47
  • you need to specify orientation (vertical in your case) and use some child views. Something like and repeat this few times inside `LinearLayout`. But also I recomend you to use some ListView (even RecyclerView) –  Ekalips Jan 20 '17 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. – Svyatoslav Jan 20 '17 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 :( – Svyatoslav Jan 20 '17 at 11:06
  • Look, `ConstraintLayout` it's just `RelativeLayout` but with more visual editing tools. In fact you can do much more with `RelativeLayout` or `LinearLayout` but you need to write it by hands. –  Ekalips Jan 20 '17 at 11:07
  • @Ekalips, okay question - is there any proper graphical tool to actually design interface for Android App? XML editing is not really something you want to deal with designing layout. Adjustments, maybe, but basic stuff should be designable in GUI. RelativeLayout screws up everything. – Svyatoslav Jan 20 '17 at 12:18
  • I've tried XML editing on Constraint->Scroll->Constraint->Content stuff.. only watching watch happens in GUI (although it shouldn't be like this), and editing there - now ScrollView is not aligned properly... trying to fix it. – Svyatoslav Jan 20 '17 at 12:20
  • Unfortunately there aren't any good visual designers for Android layout development. 90% must be written by hands. Maybe you can split your layout to mane sub layouts and than use tag to include them. –  Ekalips Jan 20 '17 at 12:22
  • did you found the solution? – sunil kushwah Mar 15 '17 at 06:04
  • @sunilkushwah No. I found the best solution is to stay away from AndroidStudio altogether, since until you need some really hard-core app, you can use Cordova/PhoneGap for most basic apps, and Unity or alternative for Gaming. Even Facebook apps made in ReactJS, not native. So why bother? – Svyatoslav Apr 16 '17 at 02:15
  • Possible duplicate of [Is it possible to put a ConstraintLayout inside a ScrollView?](https://stackoverflow.com/questions/37349845/is-it-possible-to-put-a-constraintlayout-inside-a-scrollview) – Lin Lin Jul 24 '19 at 10:04

1 Answers1

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

Anna Harrison
  • 641
  • 5
  • 13