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 8649877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:39:59+00:00 2026-06-12T13:39:59+00:00

Problem statement I’m trying to implement my own virtual keyboard following example softkeyboard, found

  • 0

Problem statement

I’m trying to implement my own virtual keyboard following example “softkeyboard”, found in samples folder of android-sdk.

In the onCreateInputView() view is created with layout inflater like this:

@Override
public View onCreateInputView() {
    mContainerView = getLayoutInflater().inflate(R.layout.my_keyboard, null);
    return mContainerView;
}

In my beautiful virtual keyboard gui definition (my_keyboard.xml) I have added some Buttons like this.

<Button
    android:id="@+id/my_button1"
    android:onClick="onMyButton1Pressed"
    android:text="@string/my_button1_text" />

Now If I run the program, Button appears to be working: onMyButton1Pressed() gets called OK. The problem is that Button state drawings (orange highlight when pressed down) do not work.

EDIT 1: Issue is same with ToggleButton: when pressed down, orange highlight won’t appear. However green “checked” mark works. If I use these in normal Activity, pressing down does give orange highlight when button is being pressed.

My findings so far, could be useful or not…

I have been trying to google, and read android documentation. Somewhere I read that using inflate with null root element, does not apply themes/styles/background-drawables/whatever (what is the correct term?) to inflated hierarchy. Is this the problem, why button states don’t show?

Now when I create virtual keyboard, what is the root element, where keyboard is added?

Also I found an alternative inflate method:

public View inflate (int resource, ViewGroup root, boolean attachToRoot)

    resource = ID for an XML layout resource to load (e.g., R.layout.main_page)
    root = Optional view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)
    attachToRoot = Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.

Could I pass this some “dummy” viewgroup from which it can extract layout params?

  • 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-06-12T13:40:00+00:00Added an answer on June 12, 2026 at 1:40 pm

    I tried background drawable + selector xml as mango suggested, and it works. So here is one possible workaround:

    1.Add background drawable to button

    <Button
        android:id="@+id/my_button1"
        android:onClick="onMyButton1Pressed"
        android:text="@string/my_button1_text" 
        android:background="@drawable/my_button_drawable
    />
    

    2.Created my_button_drawable.xml in /res/drawable/

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true"
              android:drawable="@drawable/btn_default_pressed" />
        <item android:state_enabled="false"
              android:drawable="@drawable/btn_default_transparent_normal" />
        <item android:drawable="@drawable/btn_default_normal" />
    </selector>
    

    3.Looked for button background images in: ANDROID_SDK_FOLDER/platforms/android-8/data/res/drawable-hdpi/

    • btn_default_normal.9.png (for normal state)
    • btn_default_pressed.9.png (for pressed state)
    • btn_default_transparent_normal.9.png (for disabled state)

    and added those images to drawable folder.

    Now if I press button, it gets orange highlight, and disabled state looks ok also. I don’t need focused or selected states so I didn’t include these in the selector.

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

Sidebar

Related Questions

Problem Statement is : Given 2 Dimensional array, print output for example If 4
I will explain my problem statement with the following illustration. I have 4 machines,
Following is the problem statement: I have a database table with entries that look
Problem Statement:- I am working on the android project in which I need to
I have following problem statement. Export a C++ class in the dll (un-managed). Create
Problem statement: Implement a plug-in system that allows the associated assemblies to be overwritten
Problem statement I have a worker thread that basically scans a folder, going into
Problem Statement: URLs are stored in a database, example: home/page1 gallery/image1 info/IT/contact home/page2 home/page3
If you were to read a problem statement, such as something found on TopCoder,
I am trying to figure out a solution for a problem statement. For simplicity's

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.