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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:26:44+00:00 2026-06-17T13:26:44+00:00

Today problem is that on Android 2.3.5 showing custom dialog is wrong. Dialog width

  • 0

Today problem is that on Android 2.3.5 showing custom dialog is wrong. Dialog width is wider than it should be.

enter image description here

I tried using 20dp instead of wrap_content in TextView as in LinearLayout with no success. I would like get rectangle shape with wrap_content as it is in Android 4.

Here is xml code for this custom dialog’s view.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Please wait" >
    </TextView>
</LinearLayout>

Here is a a custom dialog’s code, anything else is not important.

AlertDialog.Builder builder = new AlertDialog.Builder(context);
        AlertDialog dialog;

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.dialog_progressdialog,
                                       null);

        builder.setView(layout);

        //initializing textview

        dialog = builder.create();

        //do other stuff

On android 4.0.3 I get rectangle, so it looks ok – it is as I wanted. What might be the problem, does anyone find this kind of problem? Sorry, I don’t have sample for Android 4 – no phone today to make sample.


If I put inside also progressbar I am able to create square in android 4, but it is impossible to do it in Android 2.3.

Android 2.3.5

enter image description here

Android 4.0.4

enter image description here

  • 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-17T13:26:45+00:00Added an answer on June 17, 2026 at 1:26 pm

    I dont know whats wrong with your code. I want to have the ProgressDialog at the center of the screen. I have implemented it in to the Android 2.2.* and it works perfect in all devices even in android 4.*

    I addition i have use style to the custom progressDialog. Please see below my code and you will come to know about it.

    Java code:

    final Dialog dialog = new Dialog(SplashActivity.this,R.style.CustomDialogTheme);
            dialog.getWindow();
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.internet_dialog);
            dialog.setCancelable(false);
    
            Button retryBtn = (Button) dialog.findViewById(R.id.retryBtn);
            Button cancel = (Button) dialog.findViewById(R.id.cancelBtn);
    
            retryBtn.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    dialog.dismiss();
                                        // Some task
                }
            });
    
            cancel.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    dialog.dismiss();
                                        // Some task
                }
            });
            dialog.show();
        }
    

    CustomDialogTheme

    <style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
        <item name="android:fitsSystemWindows">true</item>
    
        <!-- <item name="android:colorBackgroundCacheHint">#00000000</item>
        <item name="android:background">#00000000</item> -->
    
    </style>
    

    And XMl file of my layout is: internet_dialog.xml

        <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#00000000"
        android:orientation="vertical" >
    
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/popup_shape"
            android:layout_margin="10dp"
            android:orientation="vertical"
            >
    
            <TextView
                android:id="@+id/net_popup_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="@string/internet_popup_heading"
                android:layout_marginTop="15dp"
                android:textColor="#ffffff"
                android:textSize="20dp" />
    
            <TextView
                android:id="@+id/net_msg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_margin="20dp"
                android:gravity="center"
                android:text="@string/internet_popup_msg"
                android:textColor="#ffffff"
                android:textSize="14dp" />
    
             <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:orientation="horizontal"
                android:gravity="center"
                android:layout_gravity="center_horizontal"
                android:padding="5dp" >
    
                <Button
                    android:id="@+id/retryBtn"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="2dp"
                    android:background="@drawable/blue_button"
                    android:textColor="#000000"
                    android:textStyle="bold"
                    android:text="@string/internet_popup_retry" />
    
                <Button
                    android:id="@+id/cancelBtn"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_marginLeft="2dp"
                    android:layout_height="wrap_content"
                    android:background="@drawable/blue_button"
                    android:textColor="#000000"
                    android:textStyle="bold"
                    android:text="@string/internet_popup_exit" />
            </LinearLayout>
        </LinearLayout>
    
    </LinearLayout>
    

    here, i havent give ant fix height/width but it seems perfect in all the layout of the any device.

    try to adding style to your dialog and see result.
    Hope it will help you.

    Feel free for comments. Enjoy Coding… 🙂

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

Sidebar

Related Questions

So today's problem is getting me mad because that should be easy and i
today my problem is that I am developing an app that is using a
I had a performance problem today that showed up after some profiling. Calls to
Hi everyone my problem today is I have a couple of buttons that slide
I got this code today that works for jQuery v7. The problem is that
Today I ran into the following problem with NUnit. I have a class, that
I ran across a problem with a SQL statement today that I was able
Today we faced a quite simple problem that were made even simpler by the
I ran into a little problem today that I can't seem to solve in
So I ran into a problem today while working on my Android program. I

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.