如何在线性布局右对齐 [英] How to right align in linear layout

查看:573
本文介绍了如何在线性布局右对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个布局我的列表项:

 < XML版本=1.0编码=UTF-8&GT?;

< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
              机器人:重力=center_vertical
              机器人:layout_width =match_parent
              机器人:方向=横向
              机器人:=了minHeight42.3dp
              机器人:layout_height =WRAP_CONTENT>

    < TextView的机器人:ID =@ + ID / txtTagName
              机器人:文字颜色=@色/白
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =32dp
              机器人:layout_marginLeft =10dp
              机器人:TEXTSIZE =13SP
              机器人:重力=中心
              机器人:layout_gravity =左
              机器人:背景=@可绘制/标签/>

    < ImageView的机器人:layout_width =WRAP_CONTENT
                 机器人:layout_height =WRAP_CONTENT
                 机器人:SRC =@可绘制/ ic_action_discard
                 机器人:layout_marginLeft =10dp
                 机器人:layout_gravity =右
                 机器人:重力=中心
                 机器人:scaleType =中心
                 机器人:阿尔法=0.5/>
< / LinearLayout中>
 

这看起来是这样的:

标签用贴片9看上去像这样:

我有3个问题:

  1. 如何让删除图标总是在正确的。
  2. 如何使标签图像比例适当的模糊部分? (它的一个补丁9)
  3. 在它是最好有一个删除图标旁边的标签,或者使用某种长按?

感谢你。

解决方案
  

如何让删除图标总是在正确的。

使用 RelativeLayout的而不是的LinearLayout 和使用属性安卓layout_alignParentRIght =真。左,右 layout_gravity 不执行任何操作在一个水平的LinearLayout 自认为的ViewGroup 已经奠定了查看 S OUT由左到右。

  

如何使标签图像比例适当的模糊部分? (它的一个补丁9)

不知道不知道更多的图像,但应该是一样的其他图像。

  

是不是最好有一个删除图标旁边的标签,或者使用某种长按?

这是相对于会使用你的应用程序,谁是用户,我想。删除图标,我认为是好的,是更加明确。但是,大多数用户的今天,尤其是年轻的可以理解为长按具体取决于您的整个应用程序的工作原理。不过,既然你有房,我想删除图标可能是好的。

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:

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.

这篇关于如何在线性布局右对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆