我尝试使用位图
从我的服务器获取图像。它工作正常,图像高分辨率,但我在 imageView 的中间看到它。 ImageView 具有完整的容器宽度。
布局代码:
<?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>
所以我的 imageView 有 id home_logo 和宽度 match_parent。 我能做错什么吗?
最佳答案
只需在 ImageView 中使用此标签即可
android:scaleType="fitXY"
按照此详细教程进行操作
http://www.peachpit.com/articles/article.aspx?p=1846580&seqNum=2
希望对您有所帮助。
关于java - Android 在 ImageView 上查看图像的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26365659/