简体   繁体   English

如何在线性布局中右对齐

[英]How to right align in linear layout

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:它看起来像这样:

在此处输入图片说明

The tag patch 9 looks like so:标签补丁 9 如下所示:

在此处输入图片说明

I have 3 questions:我有3个问题:

  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) (它是一个补丁 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" .使用RelativeLayout而不是LinearLayout并使用属性android:layout_alignParentRIght="true" left and right layout_gravity does nothing in a horizontal LinearLayout since that ViewGroup already lays View s out from left to right. left 和 right layout_gravity在水平LinearLayout中什么都不做,因为ViewGroup已经从左到右layout_gravityView

How to make the blurry part of the tag image scale properly?如何使标签图像的模糊部分正确缩放? (its a patch 9) (它是一个补丁 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"在您的 xml 项目布局中,对于删除图标的图像视图,添加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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM