0

私はこのレイアウトを使用しています:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:textColor="#372c24" />

    <View
        android:id="@+id/space"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:background="@android:color/transparent" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="horizontal" 
        android:background="@drawable/shape_popup">
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2" />
        <ImageView
            android:contentDescription="@string/app_name"
            android:id="@+id/rateStar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@drawable/image" />
    </LinearLayout>

</LinearLayout>

画像が表示されないのですが、なぜですか?

4

3 に答える 3

1

プロパティを使用する場合:

android:background=""

通常、#FFFF0000 <- Red などの色のようなものを探しており、コンテナを画像で埋めません。

適切なフィッティングで画像をコンテナーに入れるには、次のプロパティを使用する必要があります。android:src="@drawable/..."

これであなたも使うことができますandroid:scaleType="..."

コンテナー内のイメージのさまざまな縮尺タイプを変更します。

于 2012-12-16T17:53:28.743 に答える
1

ImageBiewは何らかのソースを取得するまで何も表示しないので、これを使用してください

android:src="@drawable/image"

また、重みを付けているので必要ないため、テキストビューの幅を変更します。

          <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2" />
于 2012-12-16T17:47:09.423 に答える
0

次のように android:background の代わりに android:src を使用する必要があります。

<ImageView
        android:contentDescription="@string/app_name"
        android:id="@+id/rateStar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:src="@drawable/image" />

編集:また、重みプロパティを使用しているため、android:layout_width を 0 に設定する必要があります。

        <ImageView
        android:contentDescription="@string/app_name"
        android:id="@+id/rateStar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:src="@drawable/image" />
于 2012-12-16T17:49:28.760 に答える