3

I have this layout as my list items:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:gravity="center_vertical"
              android:layout_width="match_parent"
              android:orientation="horizontal"
              android:minHeight="42.3dp"
              android:layout_height="wrap_content">

    <TextView android:id="@+id/txtTagName"
              android:textColor="@color/White"
              android:layout_width="wrap_content"
              android:layout_height="32dp"
              android:layout_marginLeft="10dp"
              android:textSize="13sp"
              android:gravity="center"
              android:layout_gravity="left"
              android:background="@drawable/tag"/>

    <ImageView android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:src="@drawable/ic_action_discard"
                 android:layout_marginLeft="10dp"
                 android:layout_gravity="right"
                 android:gravity="center"
                 android:scaleType="center"
                 android:alpha="0.5"/>
</LinearLayout>

It looks like this:

enter image description here

The tag patch 9 looks like so:

enter image description here

I have 3 questions:

  1. How to make the delete icon always on the right.
  2. How to make the blurry part of the tag image scale properly? (its a patch 9)
  3. Is it better to have a delete icon next to the tag, or use some sort of long click?

Thank you.

sprocket12
  • 5,368
  • 18
  • 64
  • 133

2 Answers2

6

How to make the delete icon always on the right.

Use RelativeLayout instead of LinearLayout and use the property android:layout_alignParentRIght="true". left and right layout_gravity does nothing in a horizontal LinearLayout since that ViewGroup already lays Views out from left to right.

How to make the blurry part of the tag image scale properly? (its a patch 9)

Not sure without knowing more about the image but should be the same as the other image.

Is it better to have a delete icon next to the tag, or use some sort of long click?

This is relative to the users who will use your app, I suppose. The delete icon I think is fine and is more explicit. However, most users nowadays, especially younger ones may understand to long click depending on how your whole app works. However, since you have the room, I think the delete icon is probably good.

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • Thanks for your reply. You said "Not sure without knowing more about the image but should be the same as the other image."... what info do you need? – sprocket12 Dec 26 '13 at 23:58
  • To be honest, I'm not great with images though can normally make mine work. So I have no idea why that one is blurry. If I had them in front of me then I could probably make it work but I'm not sure I can tell you how to fix yours. – codeMagic Dec 27 '13 at 00:00
  • That's fine, thanks for the other tips, its fixed the alignment issue and given me some confidence with displaying the delete icon. – sprocket12 Dec 27 '13 at 00:02
0
How to make the delete icon always on the right.

in your xml item layout, for your imageview of the delete icon, add android:layout_weight="0"

How to make the blurry part of the tag image scale properly? (its a patch 9)

sorry, no idea

Is it better to have a delete icon next to the tag, or use some sort of long click?

depends on the app, if there will be other options other than delete, then make all of them in long click, otherwise leave the icon, IMHO

TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50