ImageView不在真实设备上显示图像

时间:2014-06-24 13:47:57

标签: android eclipse image imageview device

我正在尝试为我的应用程序创建一个界面。在eclipse的布局预览中,一切都还可以,但是当我在真实设备上测试应用程序时,两个ImageViews都没有显示图像。我制作Android应用程序2年,但这是我第一次遇到这个问题。 eclipse布局预览的屏幕截图: enter image description here

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

我使用的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>

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

2 个答案:

答案 0 :(得分:0)

添加:

android:scaleType="fitXY"

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

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

答案 1 :(得分:0)

毕竟我用背景图像创建了一个单独的RelativeLayout,然后我把ImageView上面的按钮放在上面。它以这种方式工作。

相关问题