Indeed, a greenhorn is what I am and I really like the expression! I prefer it above new bee, but then again: spring has only started, so I hope that this season will do me some good ;-)
Being trained both as an artist and art historian, I am completely new to this android stuff. I did a course on Coursera (https://class.coursera.org/androidapps101-001) and I enjoyed it thoroughly. However, now I am rather struggling with things I thought would be easier and I am so in need of someone helping me out...
I am building an android layout with two vertical rows of images and text views. Only the thing is: the alignment of both rows is not in the middle, therefore the left row (first linear layout with vertical orientation) is far wider than the right one.
Please, let me know how I can fix this. Thanks, Fleur
This is a short version of what my xml code looks like:
It looks like your XML has some errors in it, which makes it hard to just copy and paste. For example, there is a space between the colon and o in android:orientation. This may be on purpose to avoid smilies, but it makes copy and pasting the code harder. Next time, please disable smilies on posts with XML (there is an option underneath the message area to do so). It will make life easier on us.
Another thing that makes life easier is the use of code tags. See UseCodeTags (<- that is a link) to see how.
About your problem. You are trying to control sizes of things three different ways:
1) Using android:weight so the parent pushes the size to the child
2) Using android:width="wrap_content" to make sure the parent resizes to fit the child
3) Using android:width="xxxdp" to make the child define a specific size
These things are at crosses with each other. The first one makes the parent responsible for the sizes and the second two make the child responsible for the sizes. Since you want to make the two columns equal and consistent size, you should have the parent push the sizes to the children, rather than the children push the sizes to the parent. And that is what weights do (along with 'match_parent' and 'fill_parent' width options). So, for example, you have an outer LinearLayout and two inner ones, which you want to be columns of equal size. Your basic layout would have the outer LinearLayout define a weightSum of 2, each of the inner LinearLayouts have a weight of 1, and to define the width as 0dp so it does not interfere or push a size to the parent:
Then, to make sure this width is passed from the column defining LinearLayouts onto the children text fields and images, those text and image views should define their widths as either fill_parent or match_parent:
Wow Steve, thanks so much for your two quick comments and taking the time to explain it so thoroughly to me! I am gonna dive into this tomorrow morning and hopefully after that I can celebrate my first time ever 'solved button click event' here on the JavaRanch ;-)
Otherwise I will ask again here on this forum, I am so glad with the 'be nice' policy, it makes it easy to ask around. Even if I feel like asking about something obvious.
Hip hop hurrah, that was all it took! I was not expecting it to work immediately, since I have been stumbling with Android ever since I started. So you can imagine I am thrilled. I really am! There was also another bug with the text in the textview not shown properly, but that is fixed as well.
Thanks! Ciao, Fleur ---> a happy bird on the ranch