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!! :)
精彩评论