【问题标题】:ImageView not showing image on real deviceImageView 不在真实设备上显示图像
【发布时间】:2014-06-24 13:47:56
【问题描述】:

我正在尝试为我的应用程序创建一个界面。在 Eclipse 的布局预览中,一切正常,但是当我在真实设备上测试应用程序时,两个 ImageView 没有显示图像。我做了 2 年的 Android 应用程序,但这是我第一次遇到这个问题。 Eclipse 布局预览的屏幕截图:

这是我平板电脑的屏幕截图,没有对代码进行任何更改:

我使用的xml代码很简单:

<LinearLayout 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"
android:orientation="horizontal" >

<RelativeLayout
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="2"
    android:background="#ffffff" />

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="@drawable/right_background"
    android:orientation="vertical"
    android:padding="2dp"
    android:weightSum="11" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_marginBottom="2dp"
        android:layout_weight="6"
        android:background="@drawable/upper_container" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="12312"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dp"
            android:src="@drawable/video_button" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        android:background="@drawable/bottom_container" >

        <ImageView
            android:id="@+id/imageView02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dp"
            android:src="@drawable/photo_button" />
    </RelativeLayout>
</LinearLayout>

有人知道问题可能是什么吗?谢谢。

【问题讨论】:

    标签: android eclipse image imageview device


    【解决方案1】:

    毕竟我用背景图像创建了一个单独的RelativeLayout,并将带有按钮的ImageView放在它上面。它是这样工作的。

    【讨论】:

      【解决方案2】:

      添加:

      android:scaleType="fitXY"
      

      还可以更改 imageview 的高度和宽度以填充 parent.like:

      android:layout_height="Fill_parent"
      android:layout_widtht="Fill_parent"
      

      【讨论】:

      • 这不会改变任何事情。
      猜你喜欢
      • 1970-01-01
      • 2016-10-08
      • 2023-01-18
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      • 1970-01-01
      • 2013-08-17
      • 1970-01-01
      相关资源
      最近更新 更多