[英]How to right align in linear layout
我有这个布局作为我的列表项:
<?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>
它看起来像这样:
标签补丁 9 如下所示:
我有3个问题:
谢谢。
如何使删除图标始终在右侧。
使用RelativeLayout
而不是LinearLayout
并使用属性android:layout_alignParentRIght="true"
。 left 和 right layout_gravity
在水平LinearLayout
中什么都不做,因为ViewGroup
已经从左到右layout_gravity
了View
。
如何使标签图像的模糊部分正确缩放? (它是一个补丁 9)
在不了解更多图像的情况下不确定,但应该与其他图像相同。
在标签旁边有一个删除图标更好,还是使用某种长按?
我想这与将使用您的应用程序的用户有关。 我认为删除图标很好,而且更明确。 但是,现在大多数用户,尤其是年轻用户,可能会根据整个应用程序的工作方式理解长按。 但是,既然你有房间,我认为删除图标可能很好。
How to make the delete icon always on the right.
在您的 xml 项目布局中,对于删除图标的图像视图,添加android:layout_weight="0"
How to make the blurry part of the tag image scale properly? (its a patch 9)
抱歉,不知道
Is it better to have a delete icon next to the tag, or use some sort of long click?
取决于应用程序,如果除删除之外还有其他选项,则长按所有选项,否则保留图标,恕我直言
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.