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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:15:24+00:00 2026-06-13T04:15:24+00:00

I want to display pop windows with variable sizes. The layout consist of EditView

  • 0

I want to display pop windows with variable sizes. The layout consist of EditView and I set the text on run time before displaying popup window. I want height of the new layout. I am using following code . Can anyone help where I am wrong and on wrong approach to solve my problem.

  • onsizechange method always return yOld and yNew Zero.

    private void info(String name, String Description, View v) {

        LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
        View popupView = layoutInflater.inflate(R.layout.lo_popup_concerninfo,
                null, false);
    
    
        final LinearLayout ll = (LinearLayout) popupView.findViewById(R.id.lo_popup_concern_linearlayout);
        TextView tv_concernName = (TextView) popupView
                .findViewById(R.id.tv_concernName);
        final TextView tv_concernDesc = (TextView) popupView
                .findViewById(R.id.tv_concernDesc);
        Button btn_concernDone = (Button) popupView
                .findViewById(R.id.btn_concernDone);        
    
        tv_concernName.setText(name);
        tv_concernDesc.setText(Description);
    
        ll.addView(new MyCustomView(getActivity().getApplicationContext()));
    
        Display display = getActivity().getWindowManager().getDefaultDisplay();
            //popupView.measure(display.getWidth(), display.getHeight());
       popupView.measure(View.MeasureSpec.UNSPECIFIED,   View.MeasureSpec.UNSPECIFIED); 
    
          System.out.println("view.getMeasuredWidth() " +
                  popupView.getMeasuredWidth());
                  System.out.println("view.getMeasuredHeight() " +
                  popupView.getMeasuredHeight());
    
    
    
        final PopupWindow popup = new PopupWindow(popupView,
                display.getWidth() - 40, popupView.getMeasuredHeight() + finalHeight);
    
        System.out.println("view" +
                  popup.getHeight());
    
        popup.showAtLocation(v, Gravity.CENTER, 0, 10);
        popup.setFocusable(true);
        popup.update();
    
         class MyCustomView extends View{
    
         int viewWidth = 0;
         int viewHeight = 0;
    
         public MyCustomView(Context context) {
                 super(context);
                 System.out.println("ali1");
         }
    
         @Override
         protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld){
                 super.onSizeChanged(xNew, yNew, xOld, yOld);
                 viewWidth = xNew;
                 viewHeight = yNew;
    
                 System.out.println("xNew " + xNew);
                 System.out.println("yNew " + yNew);
                 System.out.println("xOld " + xOld);
                 System.out.println("yOld " + yOld);
    
         }
    
    
         @Override
         protected void onDraw(Canvas canvas){
                 super.onDraw(canvas);
    
                 String msg = "width: " + viewWidth + "height: " + viewHeight;
                 System.out.println(msg);
         }
    }
    
  • 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-13T04:15:25+00:00Added an answer on June 13, 2026 at 4:15 am

    There was no need for MyCustomClass and override onsizechanged method to get new size of layout in my case . I spent lot of hours because of small mistake. I was using following line of code that was restricting the TextView to stretch and wrap content.

     final PopupWindow popup = new PopupWindow(popupView,
                display.getWidth() - 40, popupView.getMeasuredHeight() + finalHeight) 
    

    Now I am using following line

    final PopupWindow popup = new PopupWindow(popupView,
                    display.getWidth() - 40, ViewGroup.LayoutParams.WRAP_CONTENT);
    

    and full method is as follow.

    private void info(String name, String Description, View v) {
    
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
            View popupView = layoutInflater.inflate(R.layout.lo_popup_concerninfo,
                    null, false);
    
            LinearLayout ll = (LinearLayout) popupView
                    .findViewById(R.id.lo_popup_concern_linearlayout);
    
            TextView tv_concernName = (TextView) popupView
                    .findViewById(R.id.tv_concernName);
            final TextView tv_concernDesc = (TextView) popupView
                    .findViewById(R.id.tv_concernDesc);
            Button btn_concernDone = (Button) popupView
                    .findViewById(R.id.btn_concernDone);
            tv_concernName.setText(name);
            tv_concernDesc.setText(Description);
            Display display = getActivity().getWindowManager().getDefaultDisplay();
            popupView.measure(display.getWidth(), display.getHeight());
    
            final PopupWindow popup = new PopupWindow(popupView,
                    display.getWidth() - 40, ViewGroup.LayoutParams.WRAP_CONTENT);
    
            popup.showAtLocation(v, Gravity.CENTER, 0, 10);
            popup.setFocusable(true);
            popup.update();
    
            btn_concernDone.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                    popup.dismiss();
    
                }
            });
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Windows application in which I want to display a pop-up
i want to use facebook's fb:dialog tag to display a simple pop-up form for
I want to do a 'pop up image' using javascript to display a simple
I have a pop up window which I want to display an image and
I want to display a pop up window (div) using jquery animate ('top' and
I want display data from database in Listbox...Here is my code, It is not
i want display 1 record from colums zodys , I'm programint in C# I
I have a simple quiz application and I want display a nice timer /
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
In the header of the django admin, I want display a link. This link

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.