Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

412
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda