android - Text pushes centered elements -


i'm new mobile apps , i'm having hard time layouts. have elements centered, when put more text pushes left. how can make text goes right without pushing else?

enter image description hereenter image description here

layout:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:gravity="center">     <textview         android:text="@string/status_text"         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:id="@+id/status_view"         android:layout_margintop="59.0dp"         android:layout_height="70dp"         android:textsize="30sp" />     <imageview         android:src="@drawable/circle_green"         android:layout_width="119.5dp"         android:layout_height="80dp"         android:id="@+id/status_image"         android:layout_torightof="@id/status_view"         android:layout_margintop="37.3dp"         android:layout_marginleft="15.6dp" />     <imageview xmlns:tools="http://schemas.android.com/tools"         android:layout_width="40dp"         android:layout_height="40dp"         android:id="@+id/smoke_image"         android:src="@drawable/smoke_green"         android:layout_below="@id/status_view" />     <imageview         android:layout_width="40dp"         android:layout_height="40dp"         android:layout_below="@id/smoke_image"         android:id="@+id/motion_image"         android:src="@drawable/motion_green" />     <textview         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@id/smoke_view"         android:id="@+id/motion_view"         android:layout_torightof="@id/motion_image"         android:layout_margintop="15dp"         android:text="motion detected" />     <imageview         android:layout_width="40dp"         android:layout_height="40dp"         android:layout_below="@id/motion_image"         android:id="@+id/door_image"         android:src="@drawable/door_green" />     <textview         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@id/motion_view"         android:id="@+id/door_view"         android:layout_torightof="@id/door_image"         android:layout_margintop="13dp"         android:text="door open" />     <imageview         android:layout_width="40dp"         android:layout_height="40dp"         android:layout_below="@id/door_image"         android:id="@+id/temperature_image"         android:src="@drawable/temperature_green" />     <textview         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@id/door_view"         android:id="@+id/temperature_view"         android:layout_torightof="@id/temperature_image"         android:layout_margintop="11dp"         android:text="temperature:" />     <textview xmlns:tools="http://schemas.android.com/tools"         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/smoke_view"         android:layout_torightof="@id/smoke_image"         android:text="smoke detected"         android:layout_margintop="7dp"         android:layout_alignbottom="@id/smoke_image" /> </relativelayout> 

add android:gravity="center" text views as

<textview         android:text="@string/status_text"         android:textappearance="?android:attr/textappearancelarge"         android:layout_width="wrap_content"         android:id="@+id/status_view"         android:layout_margintop="59.0dp"         android:layout_height="70dp"         android:gravity="center"         android:textsize="30sp" /> 

edit :

instead of taking image view on left side can use android:drawableleft="@drawable/image_name"


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -