Changing the user interface with the candidate view visible on the user keyboard

I am working on custome keyboard. I set setCandidatesViewShown (true) function on onCreateCandidatesView (), the problem is that the user interface is not configured correctly.

Any help would be great. below is what i did

@Override public View onCreateCandidatesView() { LayoutInflater li = (LayoutInflater) getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View wordBar = li.inflate(R.layout.wordbar, null); LinearLayout ll = (LinearLayout) wordBar.findViewById(R.id.words); Button voiceCmd = (Button) wordBar.findViewById(R.id.voiceword); LinearLayout ll1 = null; Button voiceCmd1 = null; //comment this block in the event of showing only one keyboard so that we can only //one autocorrect bar if (isLargeScreen) { ll1 = (LinearLayout) wordBar.findViewById(R.id.words1); voiceCmd1 = (Button) wordBar.findViewById(R.id.voiceword1); } voiceCmd.setOnClickListener(voiceClickListener); mCandidateView = new CandidateView(this); mCandidateView.setService(this); setCandidatesViewShown(true); mCandidateView.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ll.addView(mCandidateView); return wordBar; } 
+3
source share
1 answer

I had the same problem. I found the answer to a post from Ced here .

The solution is to add this to your input method method,

 @Override public void onComputeInsets(InputMethodService.Insets outInsets) { super.onComputeInsets(outInsets); if (!isFullscreenMode()) { outInsets.contentTopInsets = outInsets.visibleTopInsets; } } 

Intentionally, submitting a candidate does not push the application up. From doc ,

Please note that since viewing a candidate tends to appear and hide a lot, it does not affect the application interface in the same way as the type of soft input: it will never lead to resizing of application windows, it will simply change them if necessary so that the user can see the current focus.

Hacking above increases the content area to include the candidate viewing area. The document for onComputeInsets will help you understand the concept.

Calculate interesting inserts in your interface. The default implementation uses the top of the candidate frame for visible attachments and the top of the input frame for content attachments.

+9
source

Source: https://habr.com/ru/post/1308715/


All Articles