2016-03-29 44 views
1

我在Android 4.1上的設計支持庫中遇到了TextInputLayout的一些麻煩。TextInputLayout漂浮標籤重力

所以,我有一個簡單的佈局與兩個TextInputLayout。我想提供正確的提示,因爲文本是阿拉伯文。

我設法通過使用gravity =「right」來提示右側。但是當EditText聚焦時,我注意到浮動標籤的奇怪行爲。

Floating標籤仍然粘在屏幕的左側。

我該如何同時提示提示和浮動標籤?

這裏是我的佈局:

<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:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.example.aurelien.testblablabla.MainActivity"> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="end" 
      android:hint="جزر"/> 
    </android.support.design.widget.TextInputLayout> 
    <android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="end" 
      android:hint="تفاحة"/> 
    </android.support.design.widget.TextInputLayout> 
</LinearLayout> 

這裏是結果:

enter image description here

我使用com.android.support:design:23.1.1

謝謝

回答

0

我相信你c an't自定義標籤位置TextInputLayout。無論哪種方式,如果您使用TranslationY,即使這不是更改浮動標籤位置的合適解決方案,因爲它會翻譯任何視圖。

+0

我應該簡單地禁用android 4.1及更低版本的浮動標籤嗎?我在Android 4.2及更高版本上沒有這個問題。可能是自定義TextInputLayout類可以解決問題嗎? –

+0

在4.2版本以上的Android版本中,您可以更改浮動標籤的位置,我正確地展示您告訴的內容? –

+0

對不起,我以前的消息不清楚。感謝RTL支持,我沒有在4.2和更高版本上遇到這個問題。所以我應該簡單地放棄較低版本? :)如果我必須放棄,我會! –