2014-08-31 140 views
0

在android xml中有我的布局,但图像不在布局的顶部。可能是什么问题?图像布局android

enter image description here

<?xml version="1.0" encoding="utf-8"?> 

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

    <ScrollView android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

     <LinearLayout android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical"> 

      <ImageView android:id="@+id/description_imageview" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:src="@drawable/hand" 
         android:contentDescription="@string/app_version"/> 

      <TextView android:id="@+id/first_help_textview" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="sdsjkfhsdjkfhsdkjfh skdfjh skjdfh skdjfh skjdfh skjdfh skjdhfk jshdfkjh jskdfh skjdfh skdjfh skdjfh skdjfh skjdfh skjdfh skjdfh kjsdhf kjsdhfk jhs"/> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

添加scale_type: enter image description here

enter image description here

+0

你想做什么? – 2014-08-31 11:43:50

+0

图像应该在顶部,但有一些空的空间。 – lazexe 2014-08-31 11:46:09

+0

试过android:adjustViewBounds attr? – pskink 2014-08-31 11:53:09

回答

1

尝试设置scaleType您的ImageView

android:scaleType="fitXY" 

编辑:尝试改变的LinearLayout高度:

<LinearLayout android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 
+0

对不起,但这个答案没有帮助。它的缩放图像,并有不良比例。 – lazexe 2014-08-31 11:52:33

+0

@lazexe:plz尝试编辑答案。 – 2014-08-31 12:03:39

+0

它没有帮助。没有结果.. – lazexe 2014-08-31 12:05:42

1

可能是有空格或者你可以说通过图像覆盖的一些区域是空

要么裁剪图片先形象,并消除所有空白

<ImageView android:id="@+id/description_imageview" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:src="@drawable/hand" 
        ***android:scaleType="fitXY"*** 
        android:contentDescription="@string/app_version"/> 
+0

对不起,但这个答案没有帮助。它的缩放图像和不良比例... – lazexe 2014-08-31 11:51:06

+0

因此唯一的选择是,消除图像中的空白区域,尝试在绘图或其他任何工具中打开图像以编辑和删除空白区域 – UMESH0492 2014-08-31 11:54:36

+0

在图像中没有白色空间。我已经编辑了一张图片。 – lazexe 2014-08-31 11:55:39

0
<ImageView android:id="@+id/description_imageview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/hand" 
     android:contentDescription="@string/app_version" 
     android:layout_marginTop="-5dp" 
/> 
+0

您可以添加layout_margin_Top属性 – 2015-06-17 11:02:29