11

の中にRelativeLayout入る行がありListViewます。行は次のようになります、

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

    <ImageView
        android:id="@+id/placeDetailIcon_Img"
        android:layout_height="50dp"
        android:layout_width="50dp"
        android:layout_alignParentLeft="true" 
        android:paddingBottom="20dp"
        android:paddingTop="20dp" 
        android:paddingLeft="20dp"
        android:paddingRight="20dp"/>
</RelativeLayout>

私もマージンを持って試してみました:

 <ImageView
    android:layout_height="50dp"
    android:layout_width="50dp"
    android:id="@+id/placeDetailIcon_Img" 
    android:layout_alignParentLeft="true" 
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="10dp">

の周りにマージンやパディングを適用しないでImageViewください。このタイプの間隔をどのように作成しますか?

4

3 に答える 3

5

あなたは私と一緒にこれを使うことができます:

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

     <ImageView
         android:id="@+id/imageView1"
         android:layout_width="50dp"
         android:layout_height="50dp"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:layout_marginLeft="15dp"
         android:layout_marginTop="15dp" />

</RelativeLayout>

お役に立てれば。

于 2012-04-19T22:10:31.077 に答える
3

これに対する解決策を探している他の人のために-ドキュメントから:

http://developer.android.com/reference/android/widget/RelativeLayout.html

「RelativeLayoutのサイズとその子の位置の間に循環依存関係を持つことはできないことに注意してください。たとえば、高さがWRAP_CONTENTに設定され、子がALIGN_PARENT_BOTTOMに設定されたRelativeLayoutを持つことはできません。」

また、scrollview内にrelativeViewを配置すると、奇妙な動作が発生するようです。

私の場合、relativeLayoutをwrap_contentに設定してから、ALIGN_PARENT_BOTTOM属性を使用してmarginBottomをImageViewに追加しようとしました。高さを明示的に設定すると、ようやく機能しました。

于 2014-11-17T02:59:55.197 に答える
0

LinearLayoutを使用することをお勧めします...または、属性を削除してみてください。android:layout_alignParentLeft="true"

ビューをRelativeLayoutの中央に配置する場合は、次を使用できます。

android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
于 2012-04-19T21:44:54.443 に答える