Layout Problem

  • Replies:3
Scott F.
  • Forum posts: 2

Mar 29, 2011, 9:06:41 PM via Website

Hi,

I'm trying to layout a row in a list that looks something like:

| [Pic] Description_________[CheckBox] |

Where pic and desc are aligned to the left and the checkbox is aligned to the right.
Sometimes the description is really long and I'd like it to cut off when it hits the Checkbox and do an ellipsis (...)

[Pic] Really long desc...[CheckBox]

Unfortunately I don't know of a way to get the layouts to behave this way. A horizontal linear layout will just push the checkbox off the page.

[Pic] Really long description

And a frame layout with the pic and desc with gravity left and the checkbox with gravity right, the description just goes under the checkbox:

[Pic] Really long desc[Checkbox]ion

This is good enough for now, but it doesn't look very professional.


I would like to figure out how to do this in a general fashion, not specific to a checkbox. I have other places in my app where I want the same layout except instead of a checkbox, a button, or another textbox.

Thanks,
~Scott <><

— modified on Mar 29, 2011, 9:08:12 PM

Reply
Kullorki
  • Forum posts: 55

Mar 30, 2011, 6:24:43 PM via Website

hi,
simply make this with your textview
android:layout_width="yourwidth"
android:singleLine="true"

Reply
Scott F.
  • Forum posts: 2

Mar 30, 2011, 11:21:38 PM via Website

I don't know the width of the user's screen ahead of time. Width also changes between landscape and portrait mode.

Reply
Jeremiah
  • Forum posts: 775

Mar 31, 2011, 12:37:21 AM via Website

Use dips instead of pixel measurements when you specify the width of your textbox. Dips (Density independent pixels) are scaled to the various screen sizes. See this page on developing for different screen sizes:

http://developer.android.com/guide/practices/screens_support.html

— modified on Mar 31, 2011, 12:37:53 AM

Reply