簡體   English   中英

如何在線性布局中右對齊

[英]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個問題:

  1. 如何使刪除圖標始終在右側。
  2. 如何使標簽圖像的模糊部分正確縮放? (它是一個補丁 9)
  3. 在標簽旁邊有一個刪除圖標更好,還是使用某種長按?

謝謝。

如何使刪除圖標始終在右側。

使用RelativeLayout而不是LinearLayout並使用屬性android:layout_alignParentRIght="true" left 和 right layout_gravity在水平LinearLayout中什么都不做,因為ViewGroup已經從左到右layout_gravityView

如何使標簽圖像的模糊部分正確縮放? (它是一個補丁 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM