0

Hello I need help as i Am adding an ImageView in my android xml file and i get an extra space above and below it i have tried to see the options that i can use to remove it one of them was adding android:adjustViewBounds="true" but when i do that that it removes my action Bar completely below is my code

<RelativeLayout 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"
    tools:context="com.example.fred.yebo.MainFragment">

  <ImageView
      android:id="@+id/yeboAdd"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:src="@drawable/dice"

      />

</RelativeLayout>
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
user3551487
  • 162
  • 2
  • 3
  • 15

3 Answers3

0

You can try with scaleType property of your imageView

android:scaleType="fitXY"

this line scale your image with size of your container.There are a few properties of scaleType you can try which will be better for your case.Hope to help you!

Kristiyan Varbanov
  • 2,439
  • 2
  • 17
  • 37
  • i think you must set some values to width and height to your imageview or at least set width to wrap_content, because the way you do this the image can`t look fine and will be stretch. – Kristiyan Varbanov Mar 09 '16 at 09:17
0

Try this attribute :

android:adjustViewBounds="true"

automatically scales the height of the View.

<RelativeLayout 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"
    tools:context="com.example.fred.yebo.MainFragment">

    <ImageView
        android:id="@+id/yeboAdd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/cal" />

</RelativeLayout>

Please check this answer.

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
-1
<RelativeLayout 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"
    tools:context="com.example.fred.piku.MainFragment">

    <ImageView
        android:id="@+id/pikuAdd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/dice" />

</RelativeLayout>
Hiren Patel
  • 52,124
  • 21
  • 173
  • 151