开发者

Newbie question: How do you layout an icon, 2 text lines and a button?

I am trying to extend a sample I found at http://developer.android.com/resources/articles/layout-tricks-efficiency.html. I am a brand new MonoDroid developer, just installed it yesterday, and trying to jump right into UI design and so far it is not clicking for me completely.

I have this main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip">
  <ImageView
      android:id="@+id/icon"

      android:layout_width="wrap_content"
      android:layout_height="fill_parent"

      android:layout_alignParentTop="true"
      android:layout_alignParentBottom="true"
      android:layout_marginRight="6dip"

      android:src="@drawable/icon" />

  <TextView
      android:id="@+id/secondLine"

      android:layout_width="200dip"
      android:layout_height="26dip"

      android:layout_toRightOf="@id/icon"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"

      android:singleLine="true"
      android:ellipsize="marquee"
      android:text="Second line which is a long line of text and needs to scroll" />

  <TextView
      android:id="@+id/firstLine"

      android:layout_width="200dip"
      android:layout_height="wrap_content"

      android:layout_toRightOf="@id/icon"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:layout_above="@id/secondLine"
      android:layout_alignWithParentIfMissing="true"

      android:singleLine="true"
      android:ellipsize="marquee"
      android:gravity="center_vertical"
      android:text="First line" />

  <Button
      android:id="@+id/logonButton"

      android:layout_width="50dip"
      android:layout_height="wrap_content"

      android:layout_toRightOf="@id/secondLine"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"

      android:gravity="center_vertical"
      android:text="Login" />
      />
</RelativeLayout>

What I am trying to do is have an icon on the left, 2 lines of text stacked in the middle and a button on the right. When I run this in my emulator I am seeing:

Newbie question: How do you layout an icon, 2 text lines and a button?

  1. The second 开发者_如何学JAVAline is not scrolling.
  2. The button does not show up.

Is there by any chance a simple WYSIWYG editor for layout? Or is there an app to give me a quick view of my layout XML? Something like FireBug in FireFox would be fine.

Barring the slim chance there are UI helpers for Droid, what am I doing wrong? :)

NOTE: I found hierarchyviewer and the button is not showing up at all (visible) though it does show in the heirarchy. http://screencast.com/t/rdjaR0tCM6


I think you have an extra "/>" at the bottom of . But that may not be the main issue here.

What happens if you rotate the orientation? Do you get the button then? If so, maybe you have the width of the image and text too wide to accomodate the button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜