Greetings all,
I’m trying to create a specific layout that should be very simple but having a very difficult time and was wondering if I could get some pointers.
The layout I’m looking for looks like this
Text label Text label Text Label
spinner Spinner Edit Text
The text labels and spinner columns should only take about 40% of the width total, and text label and edit text should take the remaining 60%.
I tried using a table layout, but layout_weight doesn’t seem to have any effect. The only way it seems I can set width is by hard coding the width of the items (android:width). Should I be using a table layout for this or 2 horizontal LinearLayouts? I’m wracking my mind here!
There are a lot of ways to do layouts in Android. You might consider nested LinearLayouts, whose orientation can be vertical or horizontal and you can assign layout_weight attributes to each element inside them. I don’t believe layout_weight is valid outside of a LinearLayout, and so the best you can do in a TableLayout is setting the gravity. If I understand your intention correctly, you might try something like this:
You can find more information about LinearLayout (and RelativeLayout which is a good alternative for you) from http://developer.android.com/resources/tutorials/views/hello-linearlayout.html. Good luck!