A way to adapt the position of items in an android layout - java

I am currently work on an Android project, I have to show several check-box, now they are in a Relative Layout and all are positioned to their left neighbor.
So in landscape, I have a line of check-box, the problem is if I switch in Portrait the line is cut, because there are too many elements. So is there a simple way too automatically go to the next line when the element will be cut ?
I can change the layout type (relative, linear, ...).

U may check this library flowlayout coz u cant easily achieve this behavior.

Related

Android Studio: Group elements together

I am fairly new to android studio and I am trying to make a car rental app for a university project.
I designed an app which has a horizontal slider containing blocks of different cars however I am unsure on how I would do this, I understand how the slider works and how to add elements to it.
I have a linear layout within the horizontal slider which will contain all of the blocks but I am unsure how to make a block of elements. Within the block it should have two buttons, an image and some text. Here is a picture of the design.
As you can see the available blocks are surrounded by a square. this is what I want, a small container which surrounds my data. Sort of like a div box in html.
Is there a way to do this?
Please just point me in the correct direction!
Many thanks!
It seems like cardviews can handle most of the grouping you want to do. I would reccomend looking into them because they incorporate a lot of material design components right out of the box.
https://developer.android.com/guide/topics/ui/layout/cardview

Yellow exclamation mark top-right corner component. What does it mean?

There is this annoying symbol that appears on the top right corner of a component while i was using swing and i have no idea what it means. Once it appears it becomes impossible to align the component properly which makes it infuriating.
Top-right. Yellow symbol with the exclamation in the middle:
This time (not the first time this happen) it appeared after i moved a panel to the wrong place (it was a just a order reshuffling but ended up with a new tab somehow) and after moving it back (Dragging it back using the navigator) it showed this symbol.
It isnt clickable, there is no tooltip. It is just standing there and somehow messing up with the component alignment. It probably causes more than that but i am not sure.
I got rid of it by pressing CTRL+Z but i wanna know what that means, why that even appears and how to get rid of it properly. This appeared multiple times these days and IIRC i had to delete a whole component because of it.
I am making a wild guess here. But it looks to me as if using the design view messed up your Java code. Did you check for methods that set layouts and Bounds(setLayout, setBounds) in your code? Your panel might be overlapping other components or wrongly set. There are various anomalies here. Can you upload the code?
or just check for
setBounds(int,int); //It places components according to given coordinates
setLayout() // It might be a wrong layout?

Android TextView OverLapping

I am trying to create a top bar for my app that shows the users level, coins. So i have an image view that displays the coin icon and a textview that displays the number of coins, if the number gets high it overlaps the image rather than pushing back the image and keeping everything aligned, is there a way to do that?
Without knowing your layout XML this is pure guesswork, but I'm assuming these two views are in a RelativeLayout. If so, add to one of them an attribute like this:
android:layout_toLeftOf="#id/otherViewId"
Options available are layout_toLeftOf layout_toRightOf layout_above and layout_below.
Post your layout XML and I'll update this with a better answer!
If you are using the relative layout then you can use the z-index attribute of views to manage the ordering.

Moving one element without moving others [Android ADT]

I'm currently developing an android app and I'm just wondering if there is a way to move the elements around on the graphical view without moving other elements around.
It's really a pain to get everything lined up the way I want it when moving one edittext moves 3 others too.
Thanks all!
This will depend on what your layout is so the simple answer is no. With certain layouts and attributes it might work but everything kind of depends on everything else.
If you're using a RelativeLayout then a View will be positioned relative to certain other views so this will cause problems.
If it's a LinearLayout then moving one to the top is going to move other things.
Solution
Do yourself a favor, learn to design them in the xml and don't use the graphical editor to place the Views/ViewGroups. I use the graphical tab only for checking how it looks. Using xml is easier and more flexible, IMHO

Linearly align items in a View to go to next line if space is filled

I want to show buttons in an align as shown in the pic.
If i put them in a Linearlayout with orientation Horizontal, its ok.But how can i proceed to next line?
Following image shows some TextViews align Horizontally but i have no idea how to make them go to Next Line.
There are no standard layouts (in the Andorid library) like the Swing's FlowLayout that can solve this problem. There are a couple of open source implementations of layouts that have the functionality you need. Here is an example: https://github.com/ApmeM/android-flowlayout
You could also read the answers to this question (which is essentially the same question): How can I do something like a FlowLayout in Android?

Categories

Resources