Java 布局中的图像不是完全在顶部,我想要它

Java 布局中的图像不是完全在顶部,我想要它,java,android,eclipse,layout,Java,Android,Eclipse,Layout,如果可能的话,我希望它能用图像填充整个屏幕,宽度方向,完全在顶部,在顶部和图像之间不留任何空间。这对我不起作用 这是我的main.xml代码,可能是完全错误的,如果是这样,请告诉我 任何帮助都将不胜感激,我对这方面还很陌生,所以不要害怕告诉我我错了:) 只需移除填充物即可。我希望这会有帮助 android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal

如果可能的话,我希望它能用图像填充整个屏幕,宽度方向,完全在顶部,在顶部和图像之间不留任何空间。这对我不起作用

这是我的main.xml代码,可能是完全错误的,如果是这样,请告诉我

任何帮助都将不胜感激,我对这方面还很陌生,所以不要害怕告诉我我错了:)


只需移除填充物即可。我希望这会有帮助

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
试试这个

<ImageView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_alignParentTop="true"
   android:layout_centerHorizontal="true"
   android:scaleType="centerCrop" 
   android:src="@drawable/rkz_logo"
  />

删除布局根目录中的两行

android:gravity="center"
android:paddingTop="@dimen/activity_vertical_margin" 
试试这个

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@mipmap/ic_launcher" />

<Button
    android:id="@+id/button2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_gravity="top"
    android:layout_marginBottom="30dp"
    android:clickable="true"
    android:text="Nieuws" />


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="20dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button10"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Afspraak   maken" />


    <Button
        android:id="@+id/button8"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Bezoek  tijden" />

    <Button
        android:id="@+id/button9"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Contact" />

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal">


    <Button
        android:id="@+id/button3"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Geef je mening!" />


    <Button
        android:id="@+id/button4"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text=" Route begeleiding" />

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_alignLeft="@+id/button5"
        android:layout_below="@+id/button8"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Specia-listen" />

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button5"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="BWC" />


    <Button
        android:id="@+id/button6"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="Agenda" />


    <Button
        android:id="@+id/button7"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Praktische informatie" />
</LinearLayout>


android:layout\u alignParentTop=“true”在
ImageView
的父视图上被忽略,因为它的父视图(根视图)不是
相对视图。尝试将根视图更改为
RelativeLayout
,并删除其填充(至少是顶部的填充)。

ImageView上的android:layout\u alignParentTop=“true”并删除所有android:padding**********=“@dimen/activity\u horizontal\u margin”我完全删除了这4行,没有任何更改。无论如何,谢谢:)很抱歉您还必须删除您的gravity android:gravity=“center”这将使它从左到右覆盖整个屏幕,但会完全放大我的图像。请共享屏幕截图。这样我就可以检查它的外观了?添加到帖子的顶部是图像的链接添加这个安卓:scaleType=“fitXY”而不是安卓:scaleType=“centerCrop”好的,就这样做了。显然,图像被拉出,这使得字母看起来很糟糕。这不是代码方面的,而是图像方面的。您的代码完美无缺,谢谢!:)我不知道我要怎么做,但我想我只需要创造一个自己的形象,并记住我会变宽。这很难,但我要试试。谢谢谢谢这使得顶部的空间消失,现在图像位于顶部。现在它只需要填充整个宽度。我不确定这是否可能不破坏图像,因为它可能不是合适的图像。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@mipmap/ic_launcher" />

<Button
    android:id="@+id/button2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_gravity="top"
    android:layout_marginBottom="30dp"
    android:clickable="true"
    android:text="Nieuws" />


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="20dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button10"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Afspraak   maken" />


    <Button
        android:id="@+id/button8"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Bezoek  tijden" />

    <Button
        android:id="@+id/button9"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Contact" />

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal">


    <Button
        android:id="@+id/button3"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="  Geef je mening!" />


    <Button
        android:id="@+id/button4"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text=" Route begeleiding" />

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_alignLeft="@+id/button5"
        android:layout_below="@+id/button8"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Specia-listen" />

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button5"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="BWC" />


    <Button
        android:id="@+id/button6"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="1"
        android:text="Agenda" />


    <Button
        android:id="@+id/button7"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:text="Praktische informatie" />
</LinearLayout>