从屏幕外推的观点prevent的ImageView [英] Prevent ImageView from pushing views offscreen

查看:82
本文介绍了从屏幕外推的观点prevent的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一个ImageView的和另一个线性布局,在屏幕上底栏的线性布局。我在其他地方使用的底栏在我的项目,我不认为这是问题。

I have a linear layout which contains an imageview and another linear layout which is a bottom bar on the screen. I use the bottom bar elsewhere in my project and I dont think it is the problem.

的问题是,所述的ImageView占据整个屏幕。图像本身并没有,但视图一样。我似乎无法想出解决办法。正如你可以在我的xml看到的,我不使用FILL_PARENT的图像视图,我已经尝试了图像每一个可能的scaleType。

The problem is that the imageview takes up the entire screen. The image itself doesn't, but the view does. I can't seem to figure this out. As you can see in my xml, I am not using fill_parent for the image view and I have tried every possible scaleType for the image.

有什么建议?此外,如果它可以帮助我建立到Android API 8

Any suggestions? Also if it helps I am building to Android API 8

编辑:我已经改变了下面的XML,这样就可以使用的正是我写。 (这是我在图像视图中使用的图像: http://i.imgur.com/qN5aT.jpg

I have changed the xml below so that you can use exactly what I have written. (This is the image that I use in the image view: http://i.imgur.com/qN5aT.jpg)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#FFFFFF" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:src="@drawable/quote_sample_img" />

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

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="This is text" />
    </LinearLayout>

</LinearLayout>

http://i.imgur.com/m3msH.png
(对不起,没有足够的声誉张贴实际的图片)

http://i.imgur.com/m3msH.png (Sorry not enough reputation to post the actual picture)

推荐答案

东西,看起来,如果机器人的工作:layout_weight =1.0被添加到的ImageView

Things seems to work if android:layout_weight="1.0" is added to the ImageView.

(我不确定究竟是什么发生,在布局算法什么顺序所以不能解释为什么。)

(I am unsure about what exactly is happening and in what order in the layout algorithm so can not explain why.)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#FFFFFF" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1.0"
        android:scaleType="fitStart"
        android:src="@drawable/quote_sample_img" />

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

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="This is text" />
    </LinearLayout>

</LinearLayout>

这篇关于从屏幕外推的观点prevent的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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