如何布局视图右对齐和的LinearLayout底部 [英] How to layout view right aligned and bottom of an LinearLayout

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

问题描述

我在同一直线上,右对齐试图布局1的TextView(upText)左对齐和1的TextView(downText)和图像视图(图像)两者。

我该怎么办呢?我试过,但都的TextView,并在左对齐。图像视图

 <的TextView
            机器人:ID =@ + ID / uptext
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=左/>
        <的TextView
            机器人:ID =@ + ID / downtext
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:单线=真
            机器人:重力=右|底/>
        < ImageView的
            机器人:ID =@ + ID /图像
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=右|底/>
    < / LinearLayout中>
 

解决方案

不要使用的LinearLayout 。使用 RelativeLayout的,以

  • 您的第一个的TextView 设置为安卓layout_alignParentLeft =真正的
  • 您的第二个的TextView 设置为安卓layout_alignParentBottom =真正的机器人: layout_alignParentRight =真正的
  • 相似的东西,你的的ImageView ,其中presently看起来会重叠第二的TextView

I am trying to layout 1 textview (upText) left aligned and 1 textview (downText) and an image view (image) both on the same line and right aligned.

how can I do that? I tried that, but both 'textview' and image view at left aligned.

        <TextView
            android:id="@+id/uptext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="left"/>
        <TextView
            android:id="@+id/downtext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:gravity="right|bottom"/>
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="right|bottom"/>
    </LinearLayout>

解决方案

Don't use a LinearLayout. Use a RelativeLayout, with

  • your first TextView set with android:layout_alignParentLeft="true"
  • your second TextView set with android:layout_alignParentBottom="true" and android:layout_alignParentRight="true"
  • something similar for your ImageView, which presently looks like it is going to overlap the second TextView

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

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