1

这是我的代码,它将图像放在屏幕的顶部发送者我如何将图像放在屏幕的中心?不是顶部居中我的屏幕看起来像这样 http://imgur.com/65CD6

我想放在屏幕中心而不是操作中心

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

<RelativeLayout android:id="@+id/RelativeLayout01" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_gravity="center_vertical|center_horizontal" 
android:background="#ffffff"
android:layout_height="fill_parent" 

  android:layout_width="fill_parent">


   <ImageView android:id="@+id/ImageView01" 
 android:src="@drawable/agapplogo" 
 android:layout_width="wrap_content"

 android:layout_marginLeft="60dip"
android:layout_height="wrap_content">
</ImageView>
<TextView android:id="@+id/TextView01" 
android:text="@string/welcome"
android:layout_below="@id/ImageView01" 
android:layout_width="wrap_content" 
  android:layout_height="wrap_content">
 </TextView>
   </RelativeLayout>
4

5 回答 5

1

您可以尝试使用: android:layout_centerInParent="true"如:

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



  <ImageView
      android:layout_centerInParent="true"
      android:src="@drawable/ic_launcher"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      />


</RelativeLayout>
于 2013-01-04T09:54:30.427 回答
0

地方android:gravity="center"_RelativeLayout

于 2013-01-04T09:48:37.353 回答
0

你可以android:gravity="center"<RelativeLayout>

或者

包含android:centerInParent="true"在 ImageView 中

于 2013-01-04T09:49:40.990 回答
0

只需在 xml 中为您的 ImageView 提供此属性:

    android:layout_centerHorizontal="true"
于 2013-01-04T09:49:49.447 回答
0

这可能是由于RelativeLayout,尝试使用LinearLayout

于 2013-01-04T09:50:19.790 回答