在设计视图中不显示图像

时间:2015-11-27 11:41:38

标签: android

这是我的xml文件,用于在设计视图中显示图像。我在drawable文件夹中添加了图片。但它不起作用。

<p id="log"></p>

<?xml version="1.0" encoding="utf-8"?>

4 个答案:

答案 0 :(得分:2)

试试这个

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="2">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/imageView"
        android:src="@drawable/german"
        android:layout_weight="1"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/imageView2"
        android:src="@drawable/german"
        android:layout_weight="1"/>
</LinearLayout>

答案 1 :(得分:0)

android:layout_height LinearLayout更改为 wrap_content 。不会显示高度为0dp的视图。

答案 2 :(得分:0)

这是解决方案,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >
<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:src="@drawable/ic_launcher" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:src="@drawable/ic_launcher" />
</LinearLayout>

乐于帮助和快乐编码...

答案 3 :(得分:-1)

你必须这样做:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >
<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:src="@drawable/ic_launcher" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:src="@drawable/ic_launcher" />
</LinearLayout>

当然可行。