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.

有帮助吗?

解决方案

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top