A simple custom SearchView

Picture description

description: after a simple custom SearchView, pops up the layout moves up, but only to the EditText focus, without displaying the entire custom view.

  1. wants to be able to move the lower stroke of the view to the upper part of the soft keyboard as well.
  2. now if you write the gravity property of the EditText of a custom view as bottom, you can fully display the entire view, but this is a bit ugly, is there any good way? Ask for advice.
  3. Thank you!
Mar.12,2022

solution:

set the windowSoftInputMode property in the corresponding to the interface in the AndroidManifest.xml file

<activity  
         android:name=".PhoneContactActivity"  
         android:label="@string/title_activity_phone_contact"  
         android:windowSoftInputMode="adjustPan|stateHidden" >  
     </activity>  

android:windowSoftInputMode description:

the interaction mode between activity main window and soft keyboard can be used to avoid the problem of input method panel occlusion, a new feature after Android1.5.

this is a performance that affects two things:

1. When focus is generated, whether the soft keyboard is hidden or displayed

2. Whether to reduce the size of the active main window to make room for a soft keyboard

The setting of

windowSoftInputMode must be one of the values in the following list, or a "state." Value plus a "adjust." A combination of values. Set multiple values in any group-multiple "state." Values, for example & mdash has undefined results. Use "separate" between values.

for example:

the value set here (except for "stateUnspecified" and "adjustUnspecified") will override the value set in the theme

meaning of each value:

  1. the state of the stateUnspecified: soft keyboard is not specified, and the system will choose an appropriate state or theme-dependent settings

    stateUnchanged:. When this activity appears, the soft keyboard will remain in the state of the previous activity, whether hidden or shown

    when stateHidden: users choose activity, the soft keyboard is always hidden

    stateAlwaysHidden: when the Activity main window gets focus, the soft keyboard is always hidden

    stateVisible: soft keyboard is usually visible

    when a stateAlwaysVisible: user selects activity, the soft keyboard always shows the status

    adjustUnspecified: is set by default, and it is usually up to the system to decide whether to hide or show

    .

    adjustResize: the Activity always resizes the screen to make room for the soft keyboard

    adjustPan: the contents of the current window will automatically move so that the current focus is never overridden by the keyboard and the user can always see the part of the input

for example:

AndroidManifest.xml<activity>
android:windowSoftInputMode="adjustPan"   
android:windowSoftInputMode="stateVisible|adjustResize"   
android:windowSoftInputMode="adjustPan|stateHidden" 

if you are interested in android technology, you can follow Wechat's official account: terminal R & D Department, and communicate and study with me.

Terminal R & D Department is a technology-based learning and exchange technology number, talking about technology, products, but also our lives. Be the most thoughtful and interesting Internet developer in the Eastern Hemisphere

Menu