开发者

Bubble ListView with 9-patch

开发者 https://www.devze.com 2023-03-04 06:40 出处:网络
I would like to build a listview for a discussion forum that looks like as a discussion in the iphone (i.e.: the handcent app). I saw some examples but no one uses the 9-patch.

I would like to build a listview for a discussion forum that looks like as a discussion in the iphone (i.e.: the handcent app). I saw some examples but no one uses the 9-patch.

Does 开发者_开发技巧anyone have some examples?


check this? Why do 9-patch graphics size correctly in the emulator but not on a phone? this guy got an example of a speech bubble on 9 patch. you should try experimenting with the 9 patch tool it will surely deem to be useful next time


Here my soulution: post_list_item_even.xml

<ImageView android:id="@+id/post_icon"
    android:gravity="center_horizontal|center_vertical"
    android:padding="15dip" android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true" />

<TextView android:id="@+id/post_text"
    android:gravity="center_vertical" 
    android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:layout_toRightOf="@id/post_icon" android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" android:background="@drawable/forum_bubble_even" />

post_list_item_odd.xml

<ImageView android:id="@+id/post_icon"
    android:gravity="center_horizontal|center_vertical"
    android:padding="15dip" android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" />

<TextView android:id="@+id/post_text"
    android:gravity="center_vertical" 
    android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:layout_toLeftOf="@id/post_icon" android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" android:background="@drawable/forum_bubble_odd" />

Hope it will be useful!! :)

0

精彩评论

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