问题
I have only one button in my layout and the activity has nothing. On Manifest it has the android:windowSoftInputMode="stateAlwaysVisible" for the activity, to always show the keyboard.
The problem is that when touch any key on keyboard the only one button is kind selected. Like "highlighted" the entire button in blue.
But I don't want this behavior, how can I avoid it?
Sorry I can not add images because of my reputation...
Below are my codes:
Manifest:
<activity
android:name=".MainActivityTest"
android:windowSoftInputMode="stateAlwaysVisible">
</activity>
Activity:
public class MainActivityTest extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_test);
}
}
Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/bt_testButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
回答1:
Add the following attribute to your LinearLayout can avoid this behavior:
android:focusable="true"
android:focusableInTouchMode="true"
I have tried and it works well.
来源:https://stackoverflow.com/questions/25050699/using-keyboard-with-statealwaysvisible-after-touch-any-letter-its-select-the