简体   繁体   English

空间不需要的布局和图像

[英]Space unwanted layout and image

like the title said it there are some "space" before and after an image and i don't want it. 就像标题所说它在图像之前和之后有一些“空间”,我不想要它。

<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="@drawable/fond"
    >


    <ImageView
        android:id="@+id/imageView1"
        android:contentDescription="@string/desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/top" 
        android:layout_gravity="top"        
    />

    <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="@drawable/fond1"
        >



    </LinearLayout>    
</LinearLayout>

So like you can see i have a first Layout with a background. 所以就像你可以看到我有一个背景的第一个布局。 The ImageView is just after and should be on the top but it didn't. ImageView就在之后,应该在顶部,但事实并非如此。 The second Layout is to much after the image. 第二个布局是在图像之后。 -> - >

first layout 第一个布局

--unwanted space-- - 不受欢迎的空间 -

image 图片

--unwanted space-- - 不受欢迎的空间 -

second layout 第二个布局

If anyone know how to delete this "space", thanks. 如果有人知道如何删除这个“空间”,谢谢。

Use android:adjustViewBounds="true" inside your ImageView . ImageView使用android:adjustViewBounds="true" That way your ImageView will be adjusted to the provided image bounds. 这样,您的ImageView将调整为提供的图像边界。

Use Relative layout this Way:: 以这种方式使用相对布局::

<RelativeLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:background="@drawable/fond"
   >


<ImageView
    android:id="@+id/imageView1"
    android:contentDescription="@string/desc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/top" 
    android:layout_gravity="top"  
    android:layout_alignParentTop="true"
/>

<LinearLayout 
    android:layout_below="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/fond1"
    >
</LinearLayout>    
</RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM