How to fix child in views - android

I am facing problem in fixing the child in particular place
in views or layout.
Can I fix the child at the starting and ending of Layout directly ?
Can I fix the child at the starting or ending of the view directly ?

Are you sure that you understand the different types of layouts and what is their intended purpose?
About the layouts, please look here: http://developer.android.com/guide/topics/ui/layout-objects.html
About placing child views in another view, look here: http://developer.android.com/reference/android/view/ViewGroup.html
P.S. You seem to ask lots of questions, without having a good perspective for Android. Maybe reading a book or two about the platform will be better than trying to have every little problem in your project solved here.

Related

Android Studio UI

I am kind of new to Android Studio and I have been having lots of issues with the designer. I format everything in the drag and drop designer and then as soon as I press play and run the project, all the buttons and edit texts just bunches up in the top left corner. I've searched around online and it looks like I have to learn how to use linear layouts or relative layouts and XML. Can someone explain this to me or maybe point me in the direction of a tutorial?
Seems like the root element for the .XML file is a ConstraintLayout. You should read about LinearLayouts and then RelativeLayout to get started. To explain in simple terms, a LL uses a linear heirarchy to stack views vertically or horizontally amongst each other. A RL is used to position views relative to each other, ie, the position of one view depends on position of another view. ConstraintLayout is the latest and most powerful one, which is used to reduce deep nesting of views by defining certain constraints amongst views in the layout.
Also, for future question posts, please include code snippets which you think are causing the problem. It helps a lot. Cheers!

Stack up views in RecyclerView

I'm actually a little bit confuse. I had to refactor some old code, and i've ended up with the place where hundreds of views which need to stack up on each other are just adding to RelativeLayout with
parentView.addView(m_view, 0);
Which is kinda sad. So i wanted to rewrite it as a RecyclerView elements, but instantly faced problem of their order. I can't find any examples on how to do it, maybe i google it incorrect or smth. I've tried to write my own LayoutManager, but i couldn't find any obvious way to achieve my goal.
Is there maybe another way? Or it's not that hard to order childs in RecylcerView like they are in RelativeLayout?
As was suggested in comments, i've added an image to see how i want it to look
As you can see views are lying on each other, that's what i want to achieve
I refer you to use this library.
SwipeStack : A simple, customizable and easy to use swipeable view stack for Android.

GridLayout ,TableLayout in android

in my project i have 9 image buttons which must come in 3 rows and 3 columns each image must be given a label or text beneath it as explaining it so is it good to use GridLayout or which layout will be best suitable for this situation and please suggest tutorial on suggested layout.
thanks
Here you go with it.
I would suggest you to use TableLayout if you have fixed no of views and will not change however if there is a chance of your views to increase then use GridView it uses adapter which manages memory it self.
Here is a good link to start off
http://www.androidhive.info/2011/07/android-layouts-linear-layout-relative-layout-and-table-layout/
Best of Luck

Android - how to draw in a multiple view layout

i have to draw a ball inside a view (or anything else that is good for this task).
I have followed some tutorial about the matter, but every tutorial that i have found
uses only one view (that is shown on the screen without the use of a layout).
But in my Activity i use a layout, that is composed by many views, and i want to draw
only on one of them.
here a little mockup!
Anybody knows a way to do it?
Is the view the wrong container to do it?
Thanks is advance!
Bye
...
You should extend a view that inherits from ViewGroup. this kind of view lets you handle a view that contains other views. with that, you can control the drawing, measures and layout of each of it's children separately
Your mockup can be made with a LinearLayout, which will contain some TextView's and you own View (the one which is containing the ball).
I'm surprised by this question, because there are many examples over the net explaining how to build a layout containing multiple views.

Android ScrollView layout problem

I have several ListViews in a LinearLayout. It's listing things by day, so I have a TextView containing "Sunday:" followed by a list of items, followed by a "Monday" TextView, etc. Works great, but doesn't fit in the screen. So I added a ScrollView as a parent of the LinearLayout. Now it scrolls, but the ListViews all have room for 2 entries, whether they have 0 or 3 entries. Something about adding the ScrollView parent caused the ListViews to not size dynamically. I tried calling requestLayout() on the ScrollView after the list adapters had filled their views, but that didn't do anything. Any ideas?
Edit:
From http://www.anddev.org/viewtopic.php?p=25194 and other links it seems that ListViews inside a ScrollView are not handled correctly. Anyone have a good suggestion for implementing a list-of-lists?
I'm interested in that topic too, so I did a bit of research. First: Never put a ListView in a ScrollView (as you found out yourself). Unfortunately googling this problem doesn't lead to any solutions, so I tried my suggestion from my comment above.
I implemented a custom ListAdapter and put the ListViews into one parent ListView. This doesn't work (leads to the same problem as with a ScrollView). Speaking to the guys on the official android-irc #android-dev on freenode, they told me that putting ListViews into a ListView is as bad as or even worse than putting them into a ScrollView. Unfortunately they also couldn't help me with the problem.
There seems to be only one way to achieve what you want to do; see the answer on this similar question Scrolling with Multiple ListViews for Android . The idea is to merge all ListViews into a single one by a custom adapter and to insert some kind of headers between entries. This is absolutely doable but might require some special effort.
I know it's late to answer this right now, but still - it may be useful to others who arrive here in case of similar problems.
I'd suggest that you use an Expandable ListView for this. It would solve all of your problems.
You can have the main/parent names as that of week, and when you expand it, you would have the list of entries for that particular day/week/whatever.
Also, you wouldn't have to worry about scrolling as it is taken care by android :)
If you DO try this, then please let me know if this works out for your problem
Try searching for examples on Expandable ListView.
edit:check example here - http://mylifewithandroid.blogspot.com/2008/05/expandable-lists.html

Categories

Resources