1

こんにちは、レイアウトの中心から10dpのImageViewを配置したいと思います。私にそれをするように提案してください。RelativeLayout を使用しています。

4

2 に答える 2

3

以下を試してください:

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


        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"  //   <--Sets to Horizontally center 
            android:layout_centerVertical="true"    //   <--Sets to Vertically center
            android:paddingRight="10dp"    //   <---  Sets space of 10dp at rigth, so displays to left
            android:src="@drawable/ic_launcher" />

</RelativeLayout>
于 2012-07-18T13:12:37.323 に答える
1

これを試しましたか:

   android: marginLeft="10dp"

さらに、これを読む必要があります:

RelativeLayout - Developer.android.com

于 2012-07-18T13:08:38.083 に答える