Android 以线性布局将图像视图与屏幕顶部对齐

Android 以线性布局将图像视图与屏幕顶部对齐,android,android-linearlayout,Android,Android Linearlayout,我正试图在android studio中对齐线性布局顶部的图像。我有一个空间,你可以在图片上看到。我想把那个地方清理掉。尝试了几件事都没有成功!!!有人知道怎么做吗???谢谢 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/t

我正试图在android studio中对齐线性布局顶部的图像。我有一个空间,你可以在图片上看到。我想把那个地方清理掉。尝试了几件事都没有成功!!!有人知道怎么做吗???谢谢

<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.bourgeois.michel.relativesinglescreenapp.MainActivity">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/topLinear"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

      <ImageView
        android:id="@+id/toppicture"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:src="@drawable/danielarias" />

    <TextView
        android:id="@+id/phone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:textColor="#ff6600"
        android:textStyle="bold"
        android:paddingLeft="10dp"
        android:text="Phone"/>


    <TextView
        android:id="@+id/number"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:textColor="#000"
        android:textStyle="normal"
        android:text="424-278-8938"/>


    <View
        android:id="@+id/line"
        android:layout_width="fill_parent"
        android:layout_height="2dp"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="10dp"
        android:background="#ff6600"/>
     </LinearLayout>

     <LinearLayout mlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">



    <TextView
        android:id="@+id/address"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/text"
        android:paddingBottom="20dp"
        android:paddingLeft="10dp"
        android:textColor="#000"
        android:textStyle="bold"
        android:text="Address: 5867 W 3rd St, Los Angeles, CA 90036"

        />

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button"
        android:fontFamily="sans-serif-condensed"
        android:paddingBottom="1dp"
        android:textAlignment="center"
        android:textColor="#000"
        android:textSize="16sp"
        android:text="Learn How To Dance Milonguero Tango Style!"/>

    <TextView
        android:id="@+id/thursday"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-condensed"
        android:paddingBottom="5dp"
        android:textAlignment="center"
        android:textColor="#000"
        android:textSize="16sp"
        android:text="Every Thursday Night"/>
    <TextView
        android:id="@+id/hour"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-condensed"
        android:paddingBottom="5dp"
        android:textAlignment="center"
        android:textColor="#000"
        android:textSize="16sp"
        android:text=" 8:30pm to 9:30pm"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="15dp"
        android:text="Join Us" />


问题可能与图像源的宽度和高度有关。xml中没有marginTop。尝试将
android:scaleType=“fitXY”
添加到您的
ImageView

使用您的ImageView,如:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="300dp"  
    android:scaleType="fitXY"/>  

尝试添加

android:adjustViewBounds="true"

ImageView
参数中,添加
scaleType=“fitXY”
将拉伸图像,因此请避免它。

请检查未正确添加屏幕截图。请提供有关问题的更多信息。此外,我们看不到任何图像xml布局没有任何问题请检查您的图像内部是否有空白将其放入ImageView xml中,android:scaleType=“centerCrop”感谢所有回复。我尝试了android:scaleType=“centerCrop”和android:scaleType=“fitXY”,它们都能工作。对于android:adjustViewBounds=“true”它不起作用。非常感谢你!还修复了图像,以便人们可以查看它以供将来参考。参数,添加scaleType=“fitXY”确实有效,谢谢!奇怪,因为我昨天晚上试过了,但我的浏览器被冻结了,不管怎样它都能正常工作,谢谢阿玛!