放置一个元件中的右侧在机器人的线性布局 [英] placing an element to the right in a linear layout in android

查看:201
本文介绍了放置一个元件中的右侧在机器人的线性布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲图像放置到视图的右侧。对于我tyring使用类似

I want to place an image to the right of the view. For that I am tyring to use something like

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

...some other elements

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >

    <ImageView
        android:id="@+id/imageIcon"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"            
        android:layout_gravity="right"
        android:src="@drawable/image_icon" >
    </ImageView>
</LinearLayout>

...
</RelativeLayout>

上面似乎把图像某处的中心。我如何确保图像右对齐,无论我们是否在纵向或横向模式?

The above seems to put the image somewhere in the center. How do I ensure that the image is right aligned regardless of whether we are in portrait or landscape mode?

感谢名单!

推荐答案

下面似乎工作。两个转变 1.使用方向=垂直所建议的Zortkun 2.使用WRAP_CONTENT在layout_width。

Following seems to work. Two changes 1. use orientation = vertical as suggested by Zortkun 2. Use wrap_content in layout_width.

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/settingsIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:src="@drawable/settings_icon" >
    </ImageView>
</LinearLayout>

这篇关于放置一个元件中的右侧在机器人的线性布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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