Reputation: 2545
I have a problem with the layout. I want to place one textedit and one button at the bottom of my activity. And then I want a TextView component that fills all free space on my activity's layout.
I have a big text in the bigText component that's why I need to use the ScrollView.
I have a few questions:
I don't understand, why I get a soft keyboard when I place the ScrollView component? But I don't get this keyboard without the scrollview! If I turn off the soft keyboard, like this:
getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN );
Then how I can use my EditText?
Could you help me with my layout? The problem is: when I use the ScrollView - it fills all phone's display I even see my button and EditText which should place below the ScrollView (i don't see completely bottom of my layout). How can I fix this?
And that's my fail attempt of layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/bigText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search string: " />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center_vertical|center_horizontal" >
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Go >>" />
</LinearLayout>
</LinearLayout>
Upvotes: 1
Views: 774
Reputation: 2545
Simply: getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN );
Upvotes: 0
Reputation: 4816
I'm not sure why adding a ScrollView would make the soft keyboard pop up, but it's easily remedied. Turn it off programmatically like this:
InputMethodManager manager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
IBinder binder = view.getApplicationWindowToken();
if (binder != null) {
manager.hideSoftInputFromWindow(binder, 0);
}
where view can be your ScrollView or a TextView or just about anything else
Upvotes: 1