如何在TextInputLayout中设置RTL?

时间:2016-12-12 11:16:42

标签: android

我为我搜索解决方案,但没有为我找到一些东西。

这是我的风格,TextInputLayout

<style name="MyWidget.TextInputLayout.StyleName" parent="TextAppearance.AppCompat">
    <item name="colorAccent">@color/yellow_my_mission_item_icon</item>
    <item name="android:textColorHint">@color/text_input_layout_hint_inactive</item>
    <item name="colorControlNormal">@color/black</item>
    <item name="colorControlActivated">@color/text_input_layout_active</item>
    <item name="colorControlHighlight">@color/green</item>
    <item name="android:gravity">start</item>
    <item name="android:layoutDirection">rtl</item>
    <item name="android:textAlignment">viewStart</item>
</style>

对于EditText

<style name="MyWidget.EditText.StyleName">
    <item name="android:textColor">@color/black</item>
    <item name="android:textSize">17sp</item>
    <item name="android:textAlignment">viewStart</item>
    <item name="android:gravity">start</item>
</style>

但在屏幕上看起来像是: enter image description here

1 个答案:

答案 0 :(得分:6)

根据Mavya Soni shared的Google链接,如果您使用阿拉伯语文本修改strings.xml,它将在RTL中正确显示:

#include "stdafx.h"
#include "malloc.h"
#define min(a, b)  (((a) < (b)) ? (a) : (b)) 

int* IntersectionOfArrays(int* arr1, int size1, int* arr2, int size2, int* sizeRes) 
{
    //allocating memory for the output array, it's at most the size of the smaller array
    int * res = (int*)malloc(min(size1,size2)*sizeof(int));

    int i = 0, j = 0;
    *sizeRes = 0;

    //merge_sort(arr1,0, size1-1);  //sorting the arrays//
    //merge_sort(arr2,0, size2-1);

    while (i < size1 && j < size2) 
    {
        if (arr1[i] < arr2[j])
        {
            i++;
        }
        else if (arr1[i] > arr2[j]) 
        {
            j++;
        }
        else 
        {   
            res[*sizeRes] = arr1[i]; //getting the same elements of the two arrays - the intersection values//
            i++;
            j++;
            (*sizeRes)++;
        }   
    }

    if (*sizeRes==0)  //if the intersection is empty 
        return NULL;

    return res;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int array1[]={1,2,2,2,3};
    int array2[]={1,2,3,4,5,6,7};

    int sizeRes = 0;

    int * output = IntersectionOfArrays( array1, 5, array2, 7, &sizeRes );
    return 0;
}