java - Android 在 ImageView 上查看图像的问题

标签 java android

我尝试使用位图从我的服务器获取图像。它工作正常,图像高分辨率,但我在 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。 我能做错什么吗? enter image description here

最佳答案

只需在 ImageView 中使用此标签即可

android:scaleType="fitXY" 

按照此详细教程进行操作

http://www.peachpit.com/articles/article.aspx?p=1846580&seqNum=2

enter image description here

希望对您有所帮助。

关于java - Android 在 ImageView 上查看图像的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26365659/

相关文章:

java - 将 ImageIcon 添加到 NetBeans 中的 jbutton 时出现空指针异常

java - 在 Android 上创建游戏内 Web 浏览器

android - 在运行时设置 TextView 在 RemoteView 中的位置

java - 从java中的LinkedList中删除倒数第二个节点

java - 主类中的 Swing Timer 不会重新绘制 JFrame 类

java - 将 Big xml 文件导入 Java 中嵌入的 neo4j

java - 自动发送数据到客户端,无需API调用

Android runOnUiThread - 如何传递 Activity

android - 用于启动 Android 应用程序的 DIAL 协议(protocol)

Android 推出 google maps transit