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

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

Android 4.0.4

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:
CustomDialogTheme
And XMl file of my layout is: internet_dialog.xml
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… 🙂