askIT

Android Horizontal centered logo

horizontal_centered_logo.png

You can center a logo in your design with the android layout gravity code. Use this code on the element you want to center:

android:layout_gravity="center_horizontal"

Full example of a xml layout where logo is centered:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fitsSystemWindows="true">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginRight="24dp"
        android:layout_marginLeft="24dp">


        <ImageView android:src="@drawable/logo"
            android:layout_width="wrap_content"
            android:layout_height="72dp"
            android:layout_marginTop="24dp"
            android:layout_marginBottom="24dp"
            android:layout_gravity="center_horizontal" />

    </LinearLayout>


</ScrollView>

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

No comments yet. You can be the first one to comment. Just write your comment in the form and click on the submit button.