Reputation: 626
I'm trying to align a button not right at the bottom of the screen but at a slight distance above the bottom line. How can I do that? I've tried centering the button vertically and horizontally and it works, but I need to either move the button a little below the center or a little above the bottom line.
I need to move the "PLAY" button a little lower on the screen. Additionally, I also need to scale the button down a bit, to like 80% of its current size. How can I do that?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="acevix.gladiators3.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/splash"
android:id="@+id/imageView"
android:scaleType="centerCrop"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:adjustViewBounds="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="50dp"
android:id="@+id/button3"
android:background="@drawable/play" />
</RelativeLayout>
Upvotes: 0
Views: 139
Reputation: 387
For different screen resolutions you can use intuit/sdp
add this line to your gradle file
compile 'com.intuit.sdp:sdp-android:1.0.3'
Upvotes: 1
Reputation: 21
Use this codes,
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
Try this;
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"/>
</RelativeLayout>
Update Code
Use this : android:layout_below
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="200dp"
android:layout_height="80dp"
android:layout_centerInParent="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/logo"
android:layout_centerInParent="true"
android:layout_marginTop="30dp" />
</RelativeLayout>
Upvotes: 1