Auto hide Input method when changing fragment

This commit is contained in:
PeratX 2017-05-13 21:50:02 +08:00
parent 1f4957a476
commit cd330248b7
3 changed files with 10 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package org.itxtech.daedalus.activity;
import android.Manifest;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
@ -20,6 +21,7 @@ import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import org.itxtech.daedalus.BuildConfig;
import org.itxtech.daedalus.Daedalus;
@ -334,6 +336,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.main_drawer_layout);
drawer.closeDrawer(GravityCompat.START);
InputMethodManager imm = (InputMethodManager) Daedalus.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(findViewById(R.id.id_content).getWindowToken(), 0);
return true;
}
}

View File

@ -18,8 +18,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/margin_small"
android:paddingBottom="@dimen/margin_small"
android:id="@+id/textView_custom_dns_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
@ -29,8 +29,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_custom_dns_name"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/margin_small"
android:paddingBottom="@dimen/margin_small"
android:id="@+id/textView_custom_dns_address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentBottom="true"

View File

@ -3,6 +3,7 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fragment_vertical_margin">16dp</dimen>
<dimen name="margin_small">8dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="nav_header_vertical_spacing">16dp</dimen>