I have the following the layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.company"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:orientation="horizontal"
android:id="@+id/main">
<com.company.DrawView
android:id="@+id/draw_view"
android:layout_width="900dp"
android:layout_height="500dp"
android:layout_alignParentLeft="true"
android:background="#CCCC00" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/draw_view"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="10dp"
android:clickable="true"
android:onClick="buttonClicked"
android:text="button" />
<EditText
android:id="@+id/text1"
android:textSize="5dp"
android:inputType="text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.0"
android:maxWidth="5dp"
android:visibility="invisible"
android:gravity="bottom"
/>
</LinearLayout>
</RelativeLayout>
Whenever I set the focus on the EditText, it is expanding and filling up the top half of the screen and the soft keyboard is filling up the bottom half of the screen. What should I do retain the size of the EditText and show the soft keyboard?
The intent is to capture the key strokes (on the soft keyboard) of the user and use it on another part of the application.
Edit 1:
I’m using sdk-version 15 and I am on macbook if that helps. Adding the manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ChalkrText"
android:label="@string/app_name"
android:windowSoftInputMode="adjustNothing" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I found a work around by showing the soft keyboard on clicking a button and overriding the dispatchKeyEvent in the Activity to capture the key strokes. I didn’t need the EditText and it wasn’t required to show the soft keyboard.
This is to show the soft keyboard:
This is the dispatchKeyEvent:
This is the addText method where the concerned event is handled:
These are the posts that set me in the right direction:
How to Capture soft keyboard input in a View?
Can I use the soft keyboard without an EditText?