sherifelkhatib / WidgyWidgets

Nothing imp
Apache License 2.0
34 stars 18 forks source link

Error with orientation on DialogFragment on EditTextWithCustomError #4

Open zapotec83 opened 10 years ago

zapotec83 commented 10 years ago

Hello, I am having a problem with the orientation on the DialogFragment objects when using the library with the EditTextWithCustomError to set an error.

This is the xml I am inflating : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/es.redsys.miupay" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" >

<Button
    android:id="@+id/Button_Filtrar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="Test error"
    android:textColor="#FFF"
    android:textSize="16sp" />

<mobi.sherif.widgywidgets.EditTextWithCustomError
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:ems="2"
    app:ErrorDefaultBackground="@android:drawable/alert_light_frame"
    app:ErrorDefaultBackgroundAbove="@android:drawable/alert_dark_frame"
    app:ErrorDefaultIcon="@android:drawable/presence_busy"
    app:ErrorTextColor="#f00" />

The Dialog is just doing this:

        view = dialogoBusquedaOperacion.inflate(R.layout.prueba_busqueda, null);
        final EditTextWithCustomError et_diaDesde = (EditTextWithCustomError)view.findViewById(R.id.editText1);

        et_diaDesde.setError("This is the error I am gonna show to see the distance");

And this is what is showing the error: screenshot_2014-05-19-13-54-48

As you can see, instead of showing the message on horizontal orientation, it is showing it on vertical orientation.

Do you know why there is such a problem with the orientation??

BTW, thanks a lot!! Your library is really amazing!!

zapotec83 commented 10 years ago

I realized now what's the problem. But.......I don't know how to solve it! Lol! The point is that the width of the message is the width of the EditText which has the problem minus the cursor. Do you know how to solve this?? Why is it taking the width from the EditText instead of from the parent view?

Once more time, thanks a lot for the collaboration with open source code!

davidbilly commented 9 years ago

@zapotec83 my solution : set your_edit_text_view.requestFocus(); before your_edit_text_view.setError(message);