Soft keyboard pushing views up fixed. And keyboard hides automatically when we get back to ListFragment
This commit is contained in:
		
							parent
							
								
									5935063aa3
								
							
						
					
					
						commit
						56dfa4209b
					
				| @ -4,12 +4,15 @@ | ||||
| 
 | ||||
|     <application | ||||
|         android:allowBackup="true" | ||||
|         android:fullBackupContent="true" | ||||
|         android:icon="@mipmap/ic_launcher" | ||||
|         android:label="@string/app_name" | ||||
|         android:roundIcon="@mipmap/ic_launcher_round" | ||||
|         android:supportsRtl="true" | ||||
|         android:theme="@style/AppTheme"> | ||||
|         <activity android:name=".MainActivity"> | ||||
|         <activity | ||||
|             android:name=".MainActivity" | ||||
|             android:windowSoftInputMode="adjustPan"> | ||||
|             <intent-filter> | ||||
|                 <action android:name="android.intent.action.MAIN" /> | ||||
|                 <category android:name="android.intent.category.LAUNCHER" /> | ||||
|  | ||||
| @ -15,6 +15,7 @@ import com.example.todoapp.data.viewmodel.ToDoViewModel | ||||
| import com.example.todoapp.databinding.FragmentListBinding | ||||
| import com.example.todoapp.fragments.SharedViewModel | ||||
| import com.example.todoapp.fragments.list.adapter.ListAdapter | ||||
| import com.example.todoapp.utils.hideKeyboard | ||||
| import com.google.android.material.snackbar.Snackbar | ||||
| import jp.wasabeef.recyclerview.animators.SlideInUpAnimator | ||||
| 
 | ||||
| @ -49,6 +50,9 @@ class ListFragment : Fragment(), SearchView.OnQueryTextListener { | ||||
|         // Set Menu | ||||
|         setHasOptionsMenu(true) | ||||
| 
 | ||||
|         // Hide soft keyboard | ||||
|         hideKeyboard(requireActivity()) | ||||
| 
 | ||||
|         return binding.root | ||||
|     } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										17
									
								
								app/src/main/java/com/example/todoapp/utils/Utils.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								app/src/main/java/com/example/todoapp/utils/Utils.kt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| package com.example.todoapp.utils | ||||
| 
 | ||||
| import android.app.Activity | ||||
| import android.content.Context | ||||
| import android.view.inputmethod.InputMethodManager | ||||
| 
 | ||||
| fun hideKeyboard(activity: Activity) { | ||||
|     val inputMethodManager = | ||||
|         activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||||
| 
 | ||||
|     val currentFocusedView = activity.currentFocus | ||||
|     currentFocusedView?.let { | ||||
|         inputMethodManager.hideSoftInputFromWindow( | ||||
|             currentFocusedView.windowToken, InputMethodManager.HIDE_NOT_ALWAYS | ||||
|         ) | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user