Android的布局 - 与ImageView的定位问题 [英] Android layout - alignment issue with ImageView

查看:228
本文介绍了Android的布局 - 与ImageView的定位问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一个形象的左上角一个的LinearLayout ,但与图像边框和填充占用整个窗口的宽度。

I'm trying to put an image at the top left of a LinearLayout, but with the image border and padding taking up the whole of the width of the window.

如果我尝试下面的XML,我得到我的形象与它的边框和跨页的整个宽度的白色背景,除了的该图像最终居中,而不会移动到左

If I try the XML below, I get my image with its border and a white background across the whole width of the page, except that the image ends up centered, and doesn't move to the left.

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="left"
    android:src="@drawable/banner"
    android:background="@android:color/white"
    android:padding="@dimen/d_8px"
/>

有没有办法,我还没有发现强制图像被抛在的ImageView layout_width 设置为 FILL_PARENT

在平均时间,我通过删除的ImageView 在另一个的LinearLayout ,和掉落围绕这个工作一个空的的TextView 到正确的占用水平空间的其余部分。

In the mean-time I've worked around this by dropping the ImageView inside another LinearLayout, and dropping an empty TextView to its right that takes up the rest of the horizontal space.

推荐答案

我有一个类似的问题,对此你今天早些时候说。难道这对屏幕设计观众由Eclipse插件并排侧与XML编辑器提供的,或者是你遇到了对齐问题时,实际运行的应用程序?如果是前者,那appers是在插件的错误,如果是后者,试着加入:

I was having a similar problem, to which you replied earlier today. Is this on "screen design" viewer provided by the Eclipse plugin side-by-side with the XML editor, or are you encountering the alignment problems when actually running the app? If the former, that appers to be a bug in the plugin, if the latter, try adding:

android:scaleType="fitStart"

这是我读过的文件,这似乎是最接近于你所需要的。

From the documentation I've read, that seems to be the closest to what you need.

这篇关于Android的布局 - 与ImageView的定位问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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