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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:33:28+00:00 2026-06-10T02:33:28+00:00

in my current project I have a view with some textview in the upper

  • 0

in my current project I have a view with some textview in the upper third, an edittext in the middle and a button at the bottom, all taking roughly the same space. Now when I want to enter something in the edittext, the keyboard pops up and either the view is not resized, so the keyboard hides half of the edittext, which looks crappy, or the view is resized, shrinked to half its size, which looks…very… crappy. In the iphone version of my app I made it so when I tapped the edittext it would grow and enlarge, filling the whole view, so only the edittext and the keyboard are shown. The problem is, I have absolutely no clue how to do it in Android. I already rebuild my xml layout to use relativelayout instead of linearlayout, as I thought it would be easier.
Then I put the change in the onFocusChange method like so:

et = (EditText)v.findViewById(R.id.etItems);
et.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View arg0, boolean arg1) {

        if(arg0==et) {
            if(arg1==true) {
                Log.i("EditText","got focus");
                enlargeEditText();
            } 
        } else {
            Log.i("EditText","lost focus");
        }

    }

});

private void enlargeEditText() {
   RelativeLayout.LayoutParams rllp = (LayoutParams) v.getLayoutParams();
   rllp.setMargins(0, 0, 0, 0);
   v.setLayoutParams(rllp);
}

The enlargeEditText method isnt final, I justed wanted to see if there is something changing, but…it isn’t…instead I get :

08-22 17:26:22.108: E/AndroidRuntime(20662):    at de.lochmann.einkaufsliste.FragCreateList$1.onFocusChange(FragCreateList.java:88)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.view.View.onFocusChanged(View.java:3938)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.widget.TextView.onFocusChanged(TextView.java:8465)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.widget.EditText.onFocusChanged(EditText.java:136)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.view.View.handleFocusGainInternal(View.java:3760)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.view.View.requestFocus(View.java:5453)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.view.View.requestFocus(View.java:5403)
08-22 17:26:22.108: E/AndroidRuntime(20662):    at android.view.View.requestFocus(View.java:5381)

What’s the problem? Any ideas? Thanks in advance.

  • 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-10T02:33:28+00:00Added an answer on June 10, 2026 at 2:33 am

    The error is a ClassCastException. When you adjust the layout parameters of a view you must use the parent view’s parameters. The view you want to manipulate is the RelativeLayout, but the parameters probably belong to FrameLayout. I don’t know for certain because you have only posted part of your logcat.

    This is a full LogCat trace:

    08-22 12:23:41.879: E/AndroidRuntime(12603): FATAL EXCEPTION: main
    08-22 12:23:41.879: E/AndroidRuntime(12603): java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at org.whatever.example.Example.resize(Example.java:80)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at org.whatever.example.Example.access$0(Example.java:79)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at org.whatever.example.Example$1.onFocusChange(Example.java:66)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.View.onFocusChanged(View.java:2789)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.widget.TextView.onFocusChanged(TextView.java:7198)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.View.handleFocusGainInternal(View.java:2612)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.View.requestFocus(View.java:3767)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1152)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.requestFocus(ViewGroup.java:1108)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1152)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.requestFocus(ViewGroup.java:1108)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1152)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.requestFocus(ViewGroup.java:1108)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1152)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewGroup.requestFocus(ViewGroup.java:1111)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.View.requestFocus(View.java:3718)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewRoot.performTraversals(ViewRoot.java:1285)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.os.Handler.dispatchMessage(Handler.java:99)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.os.Looper.loop(Looper.java:150)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at android.app.ActivityThread.main(ActivityThread.java:4263)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at java.lang.reflect.Method.invokeNative(Native Method)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at java.lang.reflect.Method.invoke(Method.java:507)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    08-22 12:23:41.879: E/AndroidRuntime(12603):    at dalvik.system.NativeStart.main(Native Method)
    

    You should notice that at the top there is the exception: the cause of the problem, the most vital piece of information a LogCat can give you. Also you seemed to have skipped a couple lines because I’m unaware of how the line enlargeEditText(); can compile but throw an exception…

    Anyway

    Simply change the LayoutParameters:

    FrameLayout.LayoutParams rllp = (FrameLayout.LayoutParams) v.getLayoutParams();
    rllp.setMargins(0, 0, 0, 0);
    v.setLayoutParams(rllp);
    

    It would also be nice to see how v is defined in the LayoutInflater but I’m guessing that FrameLayout.LayoutParameters is the class that you want.

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

Sidebar

Related Questions

Greetings, In my current project, I have gridview, search button, text box for search,
So I have the view file complete for a current project and now I'm
For my current project I have to send a signature from PHP to Java
In my current project I have data about colors. Each color is either a
In my current project we have a large repository of content that was originally
I have a few classes in my current project where validation of Email/Website addresses
In my current project, Workflows have comments. Please have a look at the following
On my current project, which is a delivery system, I have a list of
I have a short question. Im my current project I'm using LINQ-to-SQl. That is
I'm considering using Grails for my current project. I have a couple of requirements

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.