reenadak

2019-12-22 Center a button in Android

Dec 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"   
  7.     android:gravity="center" // magic happens here
  8.     android:orientation="horizontal"
  9.     tools:context=".MainActivity">
  10.  
  11.     <Button
  12.         android:id="@+id/mdButton"
  13.         android:layout_width="wrap_content"
  14.         android:layout_height="wrap_content"
  15.         android:text="Show Secret"
  16.         android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
  17. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment