2016-02-22 2 views
3

У меня есть проблема, что сообщение об ошибке, отображаемое текстом редактирования, перекрывает другие компоненты в макете.Редактирование текста в тексте Текст ошибки перекрывает другие компоненты

Кто-нибудь есть idead, как отобразить сообщение об ошибке позади верхних и нижних форматов?

Немного о структуре: Верхние красные и нижние серые части Линейные макеты. Основным средним содержанием является Frame Layout, содержимое которого обрабатывается приложением. В этом случае есть несколько текстов редактирования, завернутых в Scroll View.

<android.support.v4.widget.CustomDrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
tools:context=".MainActivity"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:fitsSystemWindows="true"> 

    <com.custom.TitlebarLayout 
     android:id="@+id/titlebarLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true"/> 


    <FrameLayout 
     android:id="@+id/contentContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white" 
     android:layout_gravity="top"/> 

    <com.custom.ButtonsToolbarLayout 
     android:id="@+id/buttonsToolbarLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:gravity="center_vertical|left" 
     android:orientation="horizontal"/> 

</RelativeLayout> 

Внутри contentContainer ниже макета:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:msa="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".fragment.addressedit.AddressEditFragment" 
     android:id="@+id/frame_layout_address_edit"> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/scrollview_address_dialog" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:isScrollContainer="true" 
     android:orientation="horizontal"> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_name" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearlayout_address_top" 
      android:hint="Name" 
      android:maxLength="30" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textCapCharacters" 
      android:tag="etx_name1"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_name2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_name" 
      android:hint="Name2" 
      android:maxLength="30" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textCapCharacters" 
      android:tag="etx_name2"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_street" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_name2" 
      android:hint="Street" 
      android:maxLength="30" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textCapCharacters" 
      android:tag="etx_street"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_houseno" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_street" 
      android:hint="House No." 
      android:maxLength="8" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="number" 
      msa:alternativeInputType="textNoSuggestions" 
      android:tag="etx_house_no"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_postcode" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_houseno" 
      android:hint="Postcode" 
      android:maxLength="10" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textPostalAddress" 
      android:tag="etx_postcode1" 
      msa:validation="postcode"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_city" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_postcode" 
      android:hint="City" 
      android:maxLength="30" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textCapCharacters" 
      android:tag="etx_city"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_country" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_city" 
      android:hint="Country" 
      android:maxLength="5" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="textCapCharacters" 
      android:tag="etx_country"/> 

     <com.custom.editview.EditViewLayout 
      android:id="@+id/edittext_address_phone" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/edittext_address_country" 
      android:hint="Phone" 
      android:maxLength="20" 
      android:maxLines="1" 
      android:singleLine="true" 
      android:inputType="phone" 
      android:tag="etx_phone1"/> 

    </RelativeLayout> 

</ScrollView> 

+1

не могли бы вы поделиться кодом – Rahul

+0

Что вы подразумеваете под полом верхней и нижней макета? Значит ли это в конце текста редактирования? Если это так, вы можете реализовать пользовательский текстовый вид в конце текстового макета редактирования. Вы можете разделить текст редактирования и текст с помощью относительной компоновки с фиксированным размером или даже использовать горизонтальную линейную компоновку с весом – HendraWD

+0

@HendraWijayaDjiono на прилагаемом скриншоте вы можете видеть, что на втором снимке отображается сообщение об ошибке на красной верхней панели. Я ожидаю, что ошибка будет отображаться за красной частью (так что на втором изображении не будет видимого сообщения об ошибке) – swiki

ответ

0

Дайте ошибку TextInputLayout.

... 
    txtInputLayout.setErrorEnabled(); 
    txtInputLayout.setError("error text"); 
... 

, и ошибка будет отображаться в формате edittext.

+0

Я не хочу отображать его под текстом редактирования, я хочу отобразить его за верхними красными и нижними серыми макетами. – swiki

0

Существует несколько способов решить вашу проблему.

  1. Использование Toast

    Toast.makeText(getApplicationContext(), validate_msz, Toast.LENGTH_SHORT).show(); 
    
  2. Использование Relative Layout Чтобы установить раскладку сообщение об ошибке в нижней и верхней

    <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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
        android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
        android:paddingTop="@dimen/activity_vertical_margin" 
        > 
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:gravity="bottom" 
    android:orientation="vertical" 
    android:paddingBottom="0dp"> 
    
    <Button 
        android:id="@+id/btn_password_save" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="center_horizontal" 
        android:background="#e91043" 
        android:padding="10dp" 
        android:paddingBottom="0dp" 
        android:text="SAVE " 
        android:textColor="@android:color/white" /> 
    
        </LinearLayout> 
        </RelativeLayout> 
    
  3. Используйте кнопки Плавающий действия в соответствии с вашими потребностями.

    http://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html

  4. пользовательского диалогового окна.

+0

@swiki, используйте только это в LinearLayout внутри относительного андроида: layout_alignParentBottom = "true" android: gravity = "bottom" – Laxmeena

+0

Возможно, я использовал неправильное слово в вопросе. Я имею в виду отображение за верхними и нижними макетами, бот под :) ... Я хотел бы отображать его при прокрутке вверх/вниз - не в передней части этих макетов. – swiki

Смежные вопросы