Solution 1 :
There are a few things you can do for example:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Or
<activity
...
android_windowSoftInputMode="stateHidden|adjustPan"
...
>
Another thing to try
<style name="MyTheme" parent="Theme">
<item name="android:windowSoftInputMode">stateHidden</item>
</style>
<application android_theme="@style/MyTheme">
Add these two properties to your parent layout (ex: Linear Layout, Relative Layout)
android:focusable="false"
android_focusableInTouchMode="false"
Solution 2 :
Because your widget(com.pchmn.materialchips.ChipsInput) is the first widget in Activity, there is a focus on this widget.
To solve this problem, you need to turn off the focus so that the keyboard does not open when the activity starts
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);
Manifest in tag current activity:
android:windowSoftInputMode="stateHidden"
Problem :
I’m using MaterialChipsInput. I have the following code:
<LinearLayout
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_layout_below="@id/tile_divider2"
android_orientation="vertical">
<TextView
android_id="@+id/text1"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_text="@string/header" />
<com.pchmn.materialchips.ChipsInput
android_id="@+id/chips1"
android_layout_width="match_parent"
android_layout_height="wrap_content"
app_chip_backgroundColor="@color/primaryColor"
app_chip_deletable="true"
app_chip_hasAvatarIcon="false"
app_chip_labelColor="@color/whiteColor"
app_showChipDetailed="false"
app_hint="@string/hint" />
</LinearLayout>
And the java code is:
chipsInput = (ChipsInput) findViewById(R.id.chips1);
chipsInput.addChipsListener(new ChipsInput.ChipsListener() {
@Override
public void onChipAdded(ChipInterface chip, int newSize) {}
@Override
public void onChipRemoved(ChipInterface chip, int newSize) {}
@Override
public void onTextChanged(CharSequence text) {
if (text != null && text.toString().contains(" ") && text.toString().length() > 1) {
final String tag = StringUtils.capitalizeFully(text.toString().replaceAll(" ","").trim());
if (!(tag.isEmpty())) {
chipsInput.addChip(tag, null);
}
}
}
});
For some reason, when I move to the activity and it loads the layout with that component, it automatically opens a keyboard on the ChipsInput
. What could be the reason and how to prevent it?