0

I have a Fragment that leads to another one and on the second one, there are some EditText's for the user to fill.

When I first click on any EditText, the whole fragment becomes transparent for about a second and I'm able to see the previous fragment.

Then when I click on the others EditText's, it doesn't happen anymore.

This is what happens when I click for the first time on an EditText

Messed Up Fragment

And after a second, it becomes normal

The normal Fragment

What could it be?

EDIT

My Second Fragment Layout is:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:clickable="true"
android:fillViewport="true">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="0dp"
    tools:context="com.kayan.letsapp.Fragments.AddInviteeFragment"
    android:background="@color/white"
    android:clickable="true" >


    <include android:id="@+id/header"
        layout="@layout/event_header" />

    <com.kayan.letsapp.CustomComponents.GifView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:id="@+id/loading_view"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/header"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_marginLeft="@dimen/activity_vertical_margin"
        android:layout_marginRight="@dimen/activity_vertical_margin"
        android:id="@+id/main"
        android:background="@color/white"
        android:visibility="gone">

        <com.kayan.letsapp.CustomComponents.CustomTextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/invitee_form_title"
            android:id="@+id/invitee_form_title"
            android:textSize="@dimen/text_size_medium"
            android:textColor="@color/grayLight"
            android:layout_marginTop="@dimen/margin_small"
            app:customFont="boldCondensed" />

        <com.kayan.letsapp.CustomComponents.CustomTextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/invitee_form_subtitle"
            android:layout_below="@+id/invitee_form_title"
            android:textSize="@dimen/text_size_small"
            android:textColor="@color/grayLighter"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            app:customFont="boldCondensed" />

        <com.kayan.letsapp.CustomComponents.CustomEditText
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:layout_below="@+id/invitee_form_subtitle"
            android:hint="@string/name_input"
            android:ems="10"
            android:id="@+id/name_input"
            android:background="@color/grayLightest"
            android:textColorHint="@color/grayLight"
            android:padding="10dp"
            android:layout_weight="0.2"/>

        <com.kayan.letsapp.CustomComponents.CustomEditText
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name_input"
            android:inputType="textEmailAddress"
            android:hint="@string/email_hint"
            android:ems="10"
            android:id="@+id/email_input"
            android:background="@color/grayLightest"
            android:textColorHint="@color/grayLight"
            android:layout_weight="0.2"
            android:padding="10dp"/>

        <com.kayan.letsapp.CustomComponents.CustomButton
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/add_label"
            android:layout_below="@+id/email_input"
            android:id="@+id/add_invitee"
            android:background="@drawable/primary_button"
            android:textColor="@color/white"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:layout_gravity="center_horizontal"
            />

    </RelativeLayout>

</RelativeLayout>

And this CustomEditText class is just for setting a custom font on EditText

public class CustomEditText  extends EditText{
private static final String TAG = "EditText";

public CustomEditText(Context context) {
    super(context);
}

public CustomEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
    setCustomFont(context, attrs);
}

public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setCustomFont(context, attrs);
}

private void setCustomFont(Context ctx, AttributeSet attrs) {
    TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.CustomEditText);
    String customFont = a.getString(R.styleable.CustomEditText_customFont);
    setCustomFont(ctx, customFont);
    a.recycle();
}


public boolean setCustomFont(Context ctx, String fontName) {

    Typeface tf  = FontHandler.getFont(fontName);

    if (tf == null){
        setTypeface(FontHandler.getFont("regularCondensed"));
    }
    else {
        setTypeface(tf);
    }

    return true;
}
Kayan Almeida
  • 611
  • 8
  • 15
  • Show some code/fragment/listener – Hugo Gresse Jan 13 '15 at 13:54
  • I edited my question, sorry about that. I have no listeners. – Kayan Almeida Jan 13 '15 at 14:00
  • Looks like you may be overdrawing white background in those containers. Not sure if that's your cause, but, I'd take a look at it. – wwfloyd Jan 13 '15 at 14:14
  • I noticed something, as you can see on the top of the screenshot, there's a `ViewPager` Containing the `Fragment`s. `android.support.v4.view.ViewPager`, But I don't do anything special on it. All `EditText`s that appear in my app that are not inside this `ViewPager` work fine. Could be it? – Kayan Almeida Jan 13 '15 at 14:22
  • I placed a listener that calls `mEditText.requestFocus()` on a random button on the view. The fragment becomes transparent continuously @wwfloyd – Kayan Almeida Jan 15 '15 at 16:14

1 Answers1

1

Well, I face the same thing, when I added one fragment which has some edittexts.

when I clicked one, the current fragment becomes transparent. So I use the below:

  1. Use the replace fragment to replace the add fragment (but I don't want to, when back it caused the stack fragment refresh)

  2. Add the backgroud and clickable in root

  3. Use one edittext to requestFocus()

So it's look normal, but i don't know why

Felipe Castilhos
  • 766
  • 1
  • 8
  • 18
smallfatter
  • 171
  • 1
  • 1
  • 7