I have a problem when I click to EditText
. First time nothing happened, but if I load a new fragment
and left the app, then it happened.
Flow:
- Activity Start.
- Fragment loaded.
- Click into EditText (id=myedittext) (Image: First Time) (it works good, the layout is match_parent)
- Another fragment added
- Home button (Important step!)
- Go back to app(onRestart)
- Push back button (
getSupportFragmentManager().popBackStack();
)- Click into EditText (id=myedittext)(Image: Second Time) (Err: The layout is adjustPan. Its resized when keyboard shows. WHY?)
Add fragment:
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(frameId, fragment);
transaction.addToBackStack(null);
transaction.commit();
Pop fragment:
getSupportFragmentManager().popBackStack();
Activity:
<activity
android:name=".MyActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" />
MyActivity layout:
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MyActivity">
<FrameLayout
android:fitsSystemWindows="true"
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Fragment xml details:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:gravity="center"
android:orientation="vertical">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/body"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/next_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/myedittext"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<Button
android:id="@+id/next_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/next_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
Anyone know how can I fix the screen when second time it's loaded?