Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

410
Views
Right to left in android studio

I'm using Android Studio for application development and I have a problem with placing elements in the screen.

For example: I'm trying to place a button to the right of the screen and in the studio its shown to the right of the screen but when I install the app in my smartphone i see it in the left of the screen (my smartphone is right to left configured).

How can i resolve it? (I use RelativeLayout if that matters).

Thanks!

illustration image

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The code for those who requested:

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1"><![CDATA[
    android:splitMotionEvents="true"
    tools:context="tomer.newapp.MainActivity"
    tools:layout_editor_absoluteY="81dp"
    tools:layout_editor_absoluteX="0dp">



    ]]>


    <Button
        android:id="@+id/btn"
        android:layout_width="145dp"
        android:layout_height="75dp"
        android:layout_column="2"
        android:layout_row="2"
        android:onClick="btnclick"
        android:text="Click!"
        android:textSize="30sp"
        tools:layout_editor_absoluteX="223dp"
        tools:layout_editor_absoluteY="140dp"
        android:layout_marginLeft="11dp"
        android:layout_marginStart="11dp"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

over 4 years ago · Santiago Trujillo Report

0

It would be easier to answer your question if you included some code. However, assuming your button is inside a relative parent layout which fills the screen, adding this to your button's xml code will make it align to the right:

android:layout_alignParentRight="true" 

ie.

    <Button
        android:id="@+id/btn"
        android:layout_width="145dp"
        android:layout_height="75dp"
        android:layout_alignParentRight="true"
        android:onClick="btnclick"
        android:text="Click!"
        android:textSize="30sp" />

Or to make it really easy, replace your entire XML with:

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <Button
        android:id="@+id/btn"
        android:layout_width="145dp"
        android:layout_height="75dp"
        android:onClick="btnclick"
        android:text="Click!"
        android:textSize="30sp" 
        android:layout_alignParentRight="true"/>

</RelativeLayout>
over 4 years ago · Santiago Trujillo Report

0

Note that the absolute values that you are using are in the tools namespace - this means they are not compiled into your app.

tools:layout_editor_absoluteX="223dp"
tools:layout_editor_absoluteY="140dp"

That is probably why you are getting this kind of behavior. Remove them and then see if the button moves to the left of the screen.

More about tools namespace - here

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!