[英]Android issue with view image on ImageView
I am try to get image from my server using bitmap
. 我尝试使用bitmap
从服务器获取图像。 It's work fine, image hight resolution, but i see it in the middle of my imageView. 它工作正常,图像分辨率较高,但是我在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. 所以我的imageView的ID为home_logo,宽度为match_parent。 What can i do wrong? 我该怎么办?
Just Use this tag in your ImageView 只需在ImageView中使用此标签
android:scaleType="fitXY"
Follow this details tutorial 遵循此详细信息教程
http://www.peachpit.com/articles/article.aspx?p=1846580&seqNum=2 http://www.peachpit.com/articles/article.aspx?p=1846580&seqNum=2
Hope it will helpful. 希望对您有所帮助。
您也可以通过将图像设置为imageview
背景来做到这一点
imageview.setBackgroundResource(R.drawable.your_image);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.