├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── gl │ │ └── ghkeyboard │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── gl │ │ │ └── ghkeyboard │ │ │ ├── FragmentActivity.java │ │ │ ├── Fragmernt.java │ │ │ ├── MainActivity.java │ │ │ ├── V4Fragmernt.java │ │ │ └── v4FragmentActivity.java │ └── res │ │ ├── layout │ │ ├── activity_fragment.xml │ │ ├── activity_main.xml │ │ └── fragment.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── gl │ └── ghkeyboard │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── gl │ │ └── library │ │ └── GH.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GHkeyboard 2 | 点击页面空白 回收键盘 3 | 4 | 欢迎star, 5 | 6 | #### 用法: 7 | 8 | 由于Jcenter还在审核当中,所以现在只给出笨办法, 9 | 10 | ##### 1.笨办法 11 | 将library下的GH.java复制到你自己的项目里面。 12 | 13 | 在需要的Activity或者Fragment里面添加。 14 | ``` 15 | GH.init(this); 16 | ``` 17 | 18 | #### 原理 19 | * 原理很简单,只是给DecorView设置TouchListener,隐藏键盘,并返回false。 20 | * 注意。这里所指的空白处是指除可以获取焦点之外的其他地方。 21 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | defaultConfig { 7 | applicationId "com.gl.ghkeyboard" 8 | minSdkVersion 19 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:23.2.0' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha3' 29 | testCompile 'junit:junit:4.12' 30 | compile project(':library') 31 | } 32 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\soft\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/gl/ghkeyboard/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.gl.ghkeyboard", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/gl/ghkeyboard/FragmentActivity.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.app.FragmentManager; 4 | import android.app.FragmentTransaction; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | 10 | public class FragmentActivity extends AppCompatActivity { 11 | 12 | FragmentManager manager; 13 | FragmentTransaction transaction; 14 | 15 | @Override 16 | protected void onCreate(@Nullable Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_fragment); 19 | 20 | init(); 21 | 22 | initView(); 23 | } 24 | 25 | 26 | 27 | private void init() { 28 | manager = getFragmentManager(); 29 | transaction = manager.beginTransaction(); 30 | } 31 | 32 | private void initView() { 33 | transaction.replace(R.id.content,new Fragmernt()); 34 | transaction.commit(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/gl/ghkeyboard/Fragmernt.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.app.Fragment; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.gl.library.GH; 11 | 12 | 13 | public class Fragmernt extends Fragment { 14 | 15 | 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | GH.init(this); 20 | } 21 | 22 | @Nullable 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 25 | 26 | View view = inflater.inflate(R.layout.fragment,container,false); 27 | 28 | return view; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/gl/ghkeyboard/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.gl.library.GH; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | private Button button,v4; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | GH.init(this); 20 | 21 | initView(); 22 | } 23 | 24 | private void initView() { 25 | button = (Button) findViewById(R.id.fragment); 26 | 27 | button.setOnClickListener(new View.OnClickListener() { 28 | @Override 29 | public void onClick(View v) { 30 | Intent intent = new Intent(MainActivity.this,FragmentActivity.class); 31 | startActivity(intent); 32 | } 33 | }); 34 | 35 | v4 = (Button) findViewById(R.id.v4fragment); 36 | 37 | v4.setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | Intent intent = new Intent(MainActivity.this,v4FragmentActivity.class); 41 | startActivity(intent); 42 | } 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/gl/ghkeyboard/V4Fragmernt.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.gl.library.GH; 11 | 12 | 13 | public class V4Fragmernt extends Fragment { 14 | 15 | 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | GH.init(this); 20 | } 21 | 22 | @Nullable 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 25 | 26 | View view = inflater.inflate(R.layout.fragment,container,false); 27 | 28 | return view; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/gl/ghkeyboard/v4FragmentActivity.java: -------------------------------------------------------------------------------- 1 | package com.gl.ghkeyboard; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentTransaction; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | 10 | public class v4FragmentActivity extends AppCompatActivity { 11 | 12 | FragmentManager manager; 13 | FragmentTransaction transaction; 14 | 15 | @Override 16 | protected void onCreate(@Nullable Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_fragment); 19 | 20 | init(); 21 | 22 | initView(); 23 | } 24 | 25 | 26 | 27 | private void init() { 28 | manager = getSupportFragmentManager(); 29 | transaction = manager.beginTransaction(); 30 | } 31 | 32 | private void initView() { 33 | transaction.replace(R.id.content,new V4Fragmernt()); 34 | transaction.commit(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 23 |