我想在全屏模式下为自定义Android键盘提供修改后的视图。
我发现了这个问题:This
但我不明白如何应用它。 究竟应该在setExtractView(View视图)中写一下我可以使用自己的布局?
请帮忙!
答案 0 :(得分:0)
要在全屏模式下为自定义Android键盘提供修改后的视图,您必须覆盖自定义键盘类中的 onCreateExtractTextView 方法(扩展 InputMethodService ):
@Override
public View onCreateExtractTextView() {
// edit standard layout for full-sreen mode
// androidsdk/platforms/android-26/data/res/layout/input_method_extract_view.xml
View inflater = super.onCreateExtractTextView(); // returns standard com.android.internal.R.layout.input_method_extract_view
// extract IDs from input_method_extract_view.xml
Resources res = Resources.getSystem(); // system resources
int id_inputExtractEditText = res.getIdentifier("inputExtractEditText", "id", "android"); // ExtractEditText
int id_inputExtractAccessories = res.getIdentifier("inputExtractAccessories", "id", "android"); // FrameLayout
int id_inputExtractAction = res.getIdentifier("inputExtractAction", "id", "android"); // ExtractButton
ExtractEditText inputExtractEditText = inflater.findViewById(id_inputExtractEditText);
FrameLayout inputExtractAccessories = inflater.findViewById(id_inputExtractAccessories);
Button inputExtractAction = inflater.findViewById(id_inputExtractAction);
// do anything with extracted views:
inputExtractEditText.setBackgroundColor(getResources().getColor(R.color.keyboard_backgound1));
inputExtractAccessories.setBackgroundColor(getResources().getColor(R.color.keyboard_backgound2));
inputExtractAction.setBackgroundColor(getResources().getColor(R.color.key_GradientGreen));
return inflater;
}