HOW DO I GET EDITTEXT AND SPINNER ON THE SAME LEVEL???

Put your problem here if it does not fit any of the other categories.

HOW DO I GET EDITTEXT AND SPINNER ON THE SAME LEVEL???

Postby kingkung » Fri Apr 25, 2008 11:38 pm

This is ridiculous.

I have a table layout and I'm programatically adding an EditText object and a Spinner on one table row. Simple enough, right? You'd think, since it's a TableROW, that the two objects would be level. Instead, the Spinner is always slightly below the EditText object, as seen in the picture.

Is there really no good way to fix this? I've tried setGravity(TOP) on the Spinner, but that only moves the
text to the top edge of the Spinner. I can't manually adjust the height of the Spinner because this is a TableRow, and for whatever reason, setting LayoutParams on the Spinner gives me the "Invalid LayoutParam error". Anyway, I shouldn't have to adjust the height: there should be a simple way to keep the Spinner at the same height as the EditText...

...right? Right?
Attachments
notlevel++.JPG
notlevel++.JPG (22.26 KiB) Viewed 523 times
kingkung
Freshman
Freshman
 
Posts: 9
Joined: Wed Apr 16, 2008 6:24 pm

Top

Postby kingkung » Sat Apr 26, 2008 1:22 am

Just got a response to this question on the Android developer group:

"This is because, by default, TableRow aligns widgets on their text
baseline. It is more important to have the texts aligned than the
actual object boundaries. However, next SDKs have a different Spinner
with the same height as EditText.
"

Kind of a strange decision in my opinion, but that's the way they decided to do it.
kingkung
Freshman
Freshman
 
Posts: 9
Joined: Wed Apr 16, 2008 6:24 pm

circumvent text baseline alignment

Postby georgij » Thu Jan 15, 2009 7:31 pm

No other ways known to circumvent text baseline alignment? I run in the same problem but with other controls. Well in my case I found a solution using RelativeLayout by sending the two controls to opposite directions android:layout_alignParentLeft="true" and android:layout_alignParentRight="true" but its not a replacement for a table of cause.
georgij
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed Jan 14, 2009 12:22 am
Location: Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 21 guests