Reputation: 1302
I am try to get image from my server using bitmap
. It's work fine, image hight resolution, but i see it in the middle of my imageView. Image view has full container width.
There code of layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/background"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/android_bg" />
<ImageButton
android:layout_width="160dp"
android:layout_height="40dp"
android:id="@+id/imageButton"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="@drawable/login_button"
/>
<ImageButton
android:layout_width="160dp"
android:layout_height="40dp"
android:id="@+id/imageButton2"
android:layout_marginTop="44dp"
android:background="@drawable/registration_button"
android:layout_below="@+id/imageButton"
android:layout_alignLeft="@+id/imageButton"
android:layout_alignStart="@+id/imageButton" />
<TextView
android:layout_width="160dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Bentornato"
android:id="@+id/textView2"
android:gravity="center"
android:layout_above="@+id/imageButton"
android:layout_alignLeft="@+id/imageButton"
android:layout_alignStart="@+id/imageButton"
android:layout_marginBottom="42dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="125dp"
android:id="@+id/home_logo"
/>
</RelativeLayout>
So my imageView has id home_logo and has width match_parent. What can i do wrong?
Upvotes: 0
Views: 46
Reputation: 1362
Just Use this tag in your ImageView
android:scaleType="fitXY"
Follow this details tutorial
http://www.peachpit.com/articles/article.aspx?p=1846580&seqNum=2
Hope it will helpful.
Upvotes: 2
Reputation: 6515
you can also do this by setting image as background of imageview
imageview.setBackgroundResource(R.drawable.your_image);
Upvotes: 0