0

I'm trying to make a list_item_view similar to

enter image description here

can anybody help me create it...

What i have tried

  1. made separate view for the list items i.e list_item_even and 'list_item_odd'
  2. for brevity i'll only show one of them, below is the code for list_item_even

    <TextView
        android:id="@+id/displaysms_lastmsgtime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/displaysms_contactname"
        android:layout_below="@+id/displaysms_contactname"
        android:gravity="right"
        android:text="88:88"
        android:textColor="#10bcc9"
        android:textSize="12sp"
        android:textStyle="bold" />
    
    <TextView
        android:id="@+id/displaysms_msgtext"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageButton1"
        android:layout_alignParentLeft="true"
        android:layout_alignTop="@+id/imageButton1"
        android:background="#fff"
        android:shadowColor="@color/textShadow"
        android:shadowDx="1"
        android:shadowDy="1"
        android:text="hi"
        android:textColor="@color/textColor"
        android:textSize="16sp" />
    
    
    
    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/displaysms_lastmsgtime"
        android:src="@android:drawable/btn_star" />
    
    <TextView
        android:id="@+id/displaysms_contactname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="45dp"
        android:layout_toRightOf="@+id/displaysms_msgtext"
        android:text="john"
        android:textColor="#fff"
        android:textSize="15sp"
        android:textStyle="bold"
        android:typeface="sans" />
    

and here is output

enter image description here

is it possible to create the yellow icon without using image and place an image inside it? plaese help, Regards

Dakait
  • 2,531
  • 1
  • 25
  • 43
  • 1
    Your title is misleading. I suggest you edit it to reflect the actual problem. It does not seem like your problem is with implementing alternating list-item styles. – josephus Jul 27 '14 at 22:50
  • Check out this : http://stackoverflow.com/questions/9399612/create-a-chat-bubble-in-android – Haresh Chhelana Jul 28 '14 at 07:16

2 Answers2

1

is it possible to create the yellow icon without using image and place an image inside it?

Maybe, but why put an unnecessary constraint on yourself? You can use a 9patch drawable for the yellow background thing if you're worried about stretching the pointed part. You can learn all about 9patch here.

josephus
  • 8,284
  • 1
  • 37
  • 57
0

i think you better off defining the layout programatically and check the row number if odd use one layout if even use a different one if (row%2==0) use one layout else use a different one

Mero
  • 622
  • 12
  • 24
  • i dont have a problem doing that, already taken care of it inside the list adapter, the problem is i cannot replicate the layout as shown in the first pic, i have attached the output of my layout (fig:2) which is far from similar to first one – Dakait Jul 27 '14 at 22:42