Alternating edit text hint not visible for Arabic language

心已入冬 提交于 2020-01-14 03:14:11

问题


This is kind of weird that in my page where I have 6 edit text fields, only the alternative edit texts are showing hint and rest of them are not. This happens only from Android 4.0 and onward. I don't find any reasons for this. Any suggestions would be helpful.

Here is the code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);    // Removes title bar
        setContentView(R.layout.register);

mLang = mPreference.getString("lang", "");

bBlood = (EditText) findViewById(R.id.editText8);
        bDOB = (EditText) findViewById(R.id.editText5);
        bAdd = (EditText) findViewById(R.id.editText6);
        bPhone = (EditText) findViewById(R.id.editText7);
        mProfile = (TextView) findViewById(R.id.textView1);


if(mLang.equalsIgnoreCase("English")){  
        }
        else{
            mProfile.setText(R.string.sign_up_arabic);
            bName.setHint(R.string.name_arabic);
            bDOB.setHint(R.string.name_arabic);
            bAdd.setHint(R.string.address_arabic);
            bPhone.setHint(R.string.name_arabic);
            bBlood.setHint(R.string.blood_arabic);
            mSignUp.setText(R.string.sign_arabic);
        }

And this is the layout for the above code:

<RelativeLayout 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:background="#D5D2D2"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:text="@string/sign_up"
        android:textSize="20sp" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:id="@+id/l1border"
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:layout_below="@+id/textView1"
                android:background="#000000" >
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lin1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/l1border"
                android:layout_marginTop="10dp" >

                <EditText
                    android:id="@+id/editText1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:ems="10"
                    android:hint="@string/name" >
                </EditText>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lin5"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/lin1"
                android:layout_marginTop="10dp" >

                <EditText
                    android:id="@+id/editText5"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:hint="@string/age"
                    android:inputType="number" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lin6"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/lin5"
                android:layout_marginTop="10dp" >

                <EditText
                    android:id="@+id/editText6"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:hint="@string/address" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lin7"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/lin6"
                android:layout_marginTop="10dp" >

                <EditText
                    android:id="@+id/editText7"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:hint="@string/phone"
                    android:inputType="numberDecimal" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lin8"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/lin7"
                android:layout_marginTop="10dp" >

                <EditText
                    android:id="@+id/editText8"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:hint="@string/blood" />
            </LinearLayout>

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignRight="@+id/lin8"
                android:layout_below="@+id/lin8"
                android:layout_marginTop="10dp"
                android:text="@string/sign" />
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

The Screenshot looks something like this:


回答1:


I have seen that this two EditText which have not shown hint are inputType set as "number" and "numberDecimal"., so please check one time removing input type.,It's may be creating issue.




回答2:


remove

 android:layout_below="@+id/textView1" 

from linear layout



来源:https://stackoverflow.com/questions/18572800/alternating-edit-text-hint-not-visible-for-arabic-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!