2017-07-21 1 views
0

Je vais essayer de faire ce court, donc j'ai créé cette application de connexion Bluetooth et tout fonctionne parfaitement dans mon téléphone mais j'ai remarqué un terrible problème quand je l'ai testé sur le téléphone de mon ami. Le problème est que j'utilise Linearlayout et deux boutons différents avec un fond d'image dessus pour chaque ligne qui se tient de côté, le cercle qui se trouve sur le côté gauche du rectangle qui est correct et c'est comme ça que ça marche sur mon téléphone, mais quand il s'agit de téléphone de mon ami qui a une langue différente (langue et entrée dans les paramètres Android) le cercle est sur le côté droit du rectangle.Problème de localisation et de différence de langue en android

S'il vous plaît noter que je sais déjà le fait que cela peut être corrigé s'il change la langue du téléphone en anglais comme le mien, mais je suis à la recherche d'une solution qui ne causerait aucun problème pour tous les types de mon pays avec deux langues de téléphone différentes.

Eh bien, comment suis-je censé résoudre ce problème?

How it looks on my phone

How it looks on my friend's phone

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:padding="@dimen/activity_vertical_margin"> 


<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1"> 



<FrameLayout 
android:layout_width="wrap_content" 
android:layout_height="200dp"> 


<Button 
    android:layout_width="75dp" 
    android:layout_height="70dp" 
    android:id="@+id/circle1" 
    android:background="@drawable/redcircle /> 

<Button 
    android:layout_width="75dp" 
    android:layout_height="70dp" 
    android:id="@+id/greenCircle" 
    android:background="@drawable/greencircle" 
    android:alpha="0"/> 




</FrameLayout> 


    <Button 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:layout_marginTop="5dp" 
     android:id="@+id/rect1" 
     android:text="Bluetooth Turn On/Off" 
     android:textStyle="italic" 
     android:textColor="#fdfdfd" 
     android:background="@drawable/rects" 
     android:layout_weight="1" /> 



</LinearLayout> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_weight="1.4" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <Button 
     android:layout_width="150dp" 
     android:layout_height="70dp" 
     android:id="@+id/circle2" 
     android:background="@drawable/gomb" 
     android:layout_weight="1" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:id="@+id/rect2" 
     android:textStyle="italic" 
     android:text="View paired Devices" 
     android:textColor="#fdfdfd" 
     android:enabled="false" 
     android:background="@drawable/rects" 
     android:layout_weight="1" /> 


</LinearLayout> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="0.9"> 

    <Button 
     android:layout_width="150dp" 
     android:layout_height="70dp" 
     android:id="@+id/circle3" 
     android:background="@drawable/gomb" 
     android:layout_weight="1" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:id="@+id/rect3" 
     android:textStyle="italic" 
     android:textColor="#fdfdfd" 
     android:enabled="false" 
     android:text="Scan for new Devices" 
     android:background="@drawable/rects" 
     android:layout_weight="1" /> 


</LinearLayout> 

Répondre

0

ressemble à votre téléphone d'un ami est dans une langue de droite à gauche, et votre application « soutient » droit à gauche. Tout en soutenant RTL est un objectif admirable, parfois ce n'est pas faisable.

Vous avez plusieurs options différentes ici. Le plus rapide/le plus facile pour vous est de désactiver le support RTL de votre application. Ajouter cette attr à la balise <application> dans votre AndroidManifest.xml:

android:supportsRtl="false" 

Ou, vous pouvez essayer de fournir effectivement le soutien nécessaire pour RTL au sein de votre application. Dans ce cas, cela signifie probablement spécifier un autre dessin pour l'arrière-plan de votre bouton. Si vous avez actuellement ces:

res/drawable-mdpi/background.png 
res/drawable-xhdpi/background.png 
res/drawable-xxhdpi/background.png 

Vous auriez besoin d'ajouter ces:

res/drawable-ldrtl-mdpi/background.png 
res/drawable-ldrtl-xhdpi/background.png 
res/drawable-ldrtl-xxhdpi/background.png 

Et vous mettiez la courbure sur le côté droit du bouton au lieu de la gauche.