问题描述:

I am working on RTL and LTR layouts in my Android project.

I've got two buttons - one on left, one on right. What I need is -

if user is using RTL they should stay as they are

if user is using LTR they should swap - left go to right, right go to left

How to do that?

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:background="#FFFFFF"

android:layout_height="fill_parent">

<!-- Header -->

<RelativeLayout

android:layout_width="fill_parent"

android:background="@drawable/top_header"

android:paddingLeft="5dip"

android:paddingRight="5dip"

android:layout_height="50dip">

<Button

android:layout_width="wrap_content"

android:background="@drawable/left_button"

android:layout_centerVertical="true"

android:layout_alignParentLeft="true"

android:layout_height="wrap_content">

</Button>

<Button

android:layout_width="wrap_content"

android:background="@drawable/right_button"

android:layout_centerVertical="true"

android:layout_alignParentRight="true"

android:layout_height="wrap_content">

</Button>

</RelativeLayout>

<!-- Body -->

</LinearLayout>

相关阅读:
Top