0

私のアプリケーションにはこのレイアウトがありますが、問題は、ImageViewIDを持つものがoverlay他のレイアウトの上に表示されないことです。また、Android SDK Hierarchyビューアツールでレイアウトを確認すると、ImageView高さが0で、下部に配置されています。レイアウト。私は何が欠けていますか?またはその理由は何ですか?

ありがとう。

注:Buttonこの問題は、そのビューを同じ条件のに置き換えても発生しません。ただし、、、Viewまたはで発生しImageViewます。

編集:私はImageView全体のビューを少し赤みを帯びさせるために言及を使用しています、そして私はそれをListViewアイテムとして使用しています。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/image" />

    <ImageView
        android:id="@id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"/>

    <ImageView
        android:id="@+id/overlay"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="#77ff0000" />

</RelativeLayout>
4

4 に答える 4

1

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/image" />

<ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"/>

<ImageView
    android:id="@+id/overlay"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:background="#77ff0000" />

imageviewでは、すべての配置タイプを[1].topと右または左[2].bottomと右または左のいずれかに一緒に割り当てることはできません。

于 2012-10-25T12:15:20.410 に答える
1

これは私があなたのxmlで見るものです(ダミーのテキストと画像付き)

ここに画像の説明を入力してください

1.)これはあなたが望むものですか?あなたがこれを見ていなければ私は驚かれることでしょう

2.)これが個々のリストアイテムxmlを形成する場合は、メインリストxmlで、これがパラメーターとして使用されていることを確認してください。

android:layout_width="fill_parent"
android:layout_height="wrap_content"

または、このアイテムの端が表示されない場合があります(テキストと画像が表示され、赤いオーバーレイのみが表示されるか、テキストと画像が重なる場合があります)

編集:

これが必要な場合-リストアイテムが状態のようなリストアイテムを形成するように、

ここに画像の説明を入力してください

コードを次のように変更します

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/panda" />

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="Stack Overflow"
        android:textColor="#ffffff" />


    <ImageView
        android:id="@+id/overlay"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/image"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="#77ff0000" />


</RelativeLayout>

画像とテキストを実行時に必要なものに変更します

于 2012-10-26T05:29:08.280 に答える
0

android:layout_alignParentCenter="true" 私はあなたがする必要があるのは代わりだと思います

android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"

@注:ButtonまたはImageViewに関係なく、すべてが親クラスであるViewの下にあります

于 2012-10-25T12:11:18.943 に答える
-1

ソースを設定していないため、imageViewの高さは0です。これらのバグを修正すると、次のことを試すことができます。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"/>

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/image" />

<ImageView
    android:id="@+id/overlay"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="#77ff0000" />

于 2012-10-25T12:15:04.307 に答える