Reputation: 575
this is my code which place image on top senter of screen how i place image on center of screen? not top center my screen look like this https://i.sstatic.net/pRjbD.jpg
i wanna place on center of screen not op center
<?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>
Upvotes: 1
Views: 195
Reputation: 2361
You can try to use: android:layout_centerInParent="true"
like:
<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>
Upvotes: 1
Reputation: 9870
Just give your ImageView in xml this attribute:
android:layout_centerHorizontal="true"
Upvotes: 0
Reputation: 128428
You can either play with android:gravity="center"
in <RelativeLayout>
OR
include android:centerInParent="true"
inside ImageView
Upvotes: 0