2016-08-23 66 views
1

我想在android studio中的线性布局顶部对齐图像image with space at top of picture.I在图片上可以看到空间。我想摆脱那个空间。尝试了几件事情没有成功!任何人都有一个线索如何做到这一点?由于以线性布局将图像视图对齐到屏幕顶部

<?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" /> 

+0

请检查截图是否未正确添加 –

+1

请提供有关您的问题的更多信息。我们也看不到任何图像 –

+0

xml布局没有任何问题,请检查您的图像,如果它内部有空白 – Nikhil

回答

1

使用您的ImageView,如:

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

问题可以得到你的图像源宽度和高度。在xml中没有marginTop。尝试将android:scaleType="fitXY"添加到您的ImageView

+0

感谢您的时间Batuhan它的作品!!!!! –

0

尝试ImageView参数添加

android:adjustViewBounds="true" 

,增加scaleType="fitXY"将拉伸图像,从而避免它。

+0

参数,添加scaleType =“fitXY”确实工作谢谢!奇怪,因为我昨天晚上尝试,我的浏览器被冻结无论如何它工作感谢阿马尔! –

相关问题