阻止ImageView在屏幕外推送视图

amc*_*mc6 8 android imageview android-layout android-imageview

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

问题是imageview占据了整个屏幕.图像本身没有,但视图确实如此.我似乎无法弄清楚这一点.正如你在我的xml中看到的那样,我没有在图像视图中使用fill_parent,我已经为图像尝试了所有可能的scaleType.

有什么建议?此外,如果它有助于我构建Android API 8

编辑:我已经更改了下面的xml,以便您可以完全使用我所写的内容.(这是我在图像视图中使用的图像: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>
Run Code Online (Sandbox Code Playgroud)

http://i.imgur.com/m3msH.png (抱歉没有足够的声望发布实际图片)

Hen*_*ikS 12

如果将android:layout_weight ="1.0"添加到ImageView,事情似乎有效.

(我不确定究竟发生了什么以及布局算法中的顺序,因此无法解释原因.)

<?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>
Run Code Online (Sandbox Code Playgroud)