0

In my app i used an image view ,i chose width and height as ,match_parent ,and fill_parent,but the image is still smaller than my screen size.What is wrong with this code.I know its a foolish question,i am new to android i want to fix this issue,can anybody give a solution?

My xml

<?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">
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:id="@+id/imageView" />
<Button
        android:id="@+id/btnAddExpense"
        android:layout_width="wrap_content"
        android:layout_height="45dp"

        android:text="Skip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>

image view

<?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">
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:adjustViewBounds="true"
        android:id="@+id/imageView" />
<Button
        android:id="@+id/btnAddExpense"
        android:layout_width="wrap_content"
        android:layout_height="45dp"

        android:text="Skip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
jibinj
  • 1
  • 1
  • 4

1 Answers1

2

By default, contents of an ImageView control are of a certain size -- usually the size of the image dimensions. In order to fix that you need to add android:adjustViewBounds="true" to your ImageView and android:scaleType="fitXY"

Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
  • I have added it but still the problem is not solved.Any other changes?? – jibinj Apr 26 '15 at 18:53
  • Hi, i have added ,android:adjustViewBounds="true", and also the scale type = fitXY,but no changes in the display ,still problem remains , – jibinj Apr 26 '15 at 19:05
  • You can play around with your imageview parameters, use https://guides.codepath.com/android/Working-with-the-ImageView#overview but I am pretty sure it should have been working by now. Maybe you need to tell the imageview to be above the button, but appart from that, you lost me. – Bojan Kseneman Apr 26 '15 at 19:12
  • Thanx, I dont know what is the actual problem, please see my edit – jibinj Apr 26 '15 at 19:28