lazexe
lazexe

Reputation: 369

Image layout android

There is my layout in android xml, but the image does not in the top of the layout. What can be the problem?

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>

add scale_type: enter image description here

enter image description here

Upvotes: 0

Views: 478

Answers (3)

Pratik Lad
Pratik Lad

Reputation: 464

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

Upvotes: 0

Arash GM
Arash GM

Reputation: 10395

try Setting scaleType to your ImageView

 android:scaleType="fitXY"

Edit : Try Changing LinearLayout height :

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

Upvotes: 1

UMESH0492
UMESH0492

Reputation: 1731

might be your image having white spaces or you can say some area covered by image is null

either crop your image first and eliminate all white space

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

Upvotes: 1

Related Questions