Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7016295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:45:57+00:00 2026-05-27T22:45:57+00:00

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

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:45:58+00:00Added an answer on May 27, 2026 at 10:45 pm

    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:

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    

    This is the dispatchKeyEvent:

    public boolean dispatchKeyEvent(KeyEvent event) {
    /**
     * ACTION_MULTIPLE is for keys with special characters like &copy;
     * British Pound sign etc. These keys do not generate the ACTION_DOWN
     * or ACTION_UP events.
     * 
     * Only the ACTION_DOWN is handled. ACTION_UP is ignored to avoid
     * duplication of the letters that the user wants to type.
     */
    if (event.getAction() == KeyEvent.ACTION_DOWN ||
        event.getAction() == KeyEvent.ACTION_MULTIPLE) {
    
        DrawView dview = (DrawView) findViewById(R.id.draw_view);
            Log.v(LOG_TAG, "c = " + event.getKeyCode() + 
                        ", l = " + event.getDisplayLabel() + 
                        ", u = " + event.getUnicodeChar() +
                        ", uc = " + (char)event.getUnicodeChar() + 
                        ", chars = " + event.getCharacters()
                );
            dview.addText(event);
    }
    return true;
    }
    

    This is the addText method where the concerned event is handled:

    public void addText(KeyEvent event) {
        int unicode = event.getUnicodeChar();
        int keycode = event.getKeyCode();
        String characters = event.getCharacters();
    
        if (unicode == 0) {
            switch (keycode) {
            case 0:
                if (characters != null) {
                    text += characters;
                }
                break;
            case KeyEvent.KEYCODE_DEL:
                text = text.substring(0, text.length()-1);
                break;
            case KeyEvent.KEYCODE_SHIFT_LEFT:
            case KeyEvent.KEYCODE_SHIFT_RIGHT:
                // ignore, nothing to do
                break;
            }
        }
        else {
            text = text + (char)unicode;
        }
    
        invalidate();
    }
    

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have the following layout in XML (splashscreen.xml): <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/frmLayout
I have the following main.xml file with a LinearLayout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have the following layout defined for one of my Activities: <?xml version=1.0 encoding=utf-8?>
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
I have the following layout in my xml file: <RelativeLayout android:layout_width=fill_parent android:layout_height=fill_parent> <FrameLayout android:id=@+id/logoLayout
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have created a custom Button as follows. file : buttoncontrol.xml <?xml version=1.0 encoding=utf-8?>
I have created bg3.9.png image following this tutorial http://developer.android.com/guide/developing/tools/draw9patch.html but when i put it
I have the following xml file for navigation bar layout: navigation_bar.xml EDIT: I simplified

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.