我的浮动按钮有个小问题,浮动按钮位于右下角。当我单击英语时,它会显示相同的位置。
现在,我要说的是,如何将浮动按钮翻译成阿拉伯语时留在同一位置,因为当我单击阿拉伯语时,浮动按钮内的项目位于屏幕的左侧。
<?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"
android:background="@color/dd"
tools:context="com.egov.SharjahPoliceSmartApp.activity.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<include
android:id="@+id/footer"
layout="@layout/footer_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true" />
<LinearLayout
android:id="@+id/ParentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/footer"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:background="@drawable/dash_bg"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp">
<ImageView
android:id="@+id/Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/LogoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="@drawable/logo_text" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/RecycleView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1" />
</LinearLayout>
<View
android:visibility="gone"
android:id="@+id/DimLayout"
android:layout_above="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blackTransparent"
/>
<RelativeLayout
android:id="@+id/Dashboard"
style="@style/fab_parent"
android:layout_marginBottom="160dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Dashboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt"
android:src="@drawable/img_2"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:id="@+id/txt"
android:duplicateParentState="false"
style="@style/fab_style_txt"
android:text="@string/dashboard" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Library"
style="@style/fab_parent"
android:layout_marginBottom="110dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Library"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt2"
android:src="@drawable/img_1"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:duplicateParentState="false"
android:id="@+id/txt2"
style="@style/fab_style_txt"
android:text="@string/library" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Store"
style="@style/fab_parent"
android:layout_marginBottom="60dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Store"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt3"
android:src="@drawable/img_3"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:duplicateParentState="true"
android:id="@+id/txt3"
style="@style/fab_style_txt"
android:text="@string/store" />
</RelativeLayout>
<LinearLayout
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin">
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:0)
将所有收藏夹按钮放入RelativeLayout并设置android:layoutDirection =“ ltr”:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="ltr"/>
<RelativeLayout
android:id="@+id/Dashboard"
style="@style/fab_parent"
android:layout_marginBottom="160dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Dashboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt"
android:src="@drawable/img_2"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:id="@+id/txt"
android:duplicateParentState="false"
style="@style/fab_style_txt"
android:text="@string/dashboard" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Library"
style="@style/fab_parent"
android:layout_marginBottom="110dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Library"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt2"
android:src="@drawable/img_1"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:duplicateParentState="false"
android:id="@+id/txt2"
style="@style/fab_style_txt"
android:text="@string/library" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Store"
style="@style/fab_parent"
android:layout_marginBottom="60dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_Store"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/txt3"
android:src="@drawable/img_3"
app:backgroundTint="@color/white"
app:elevation="6dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
<TextView
android:duplicateParentState="true"
android:id="@+id/txt3"
style="@style/fab_style_txt"
android:text="@string/store" />
</RelativeLayout>
</RelativeLayout>