Why I am not able to see proper custom dialog Box in Motorola Atrix Emulator?

断了今生、忘了曾经 提交于 2019-12-06 11:02:36

I know this has been answered but here is how I did it...

I saw this on all my Motorola phones X2, Razr...Seems to definitely be a bug in the styles for Motorola.

I fixed it by creating my own style and copying panel_background from my \android-sdk\platforms\android-10\data\res\drawable-hdpi and placing it in my drawable. Eclipse wouldn't compile if I referenced it using @android:drawable/panel_background.

styles.xml

<style name="Theme.CustomDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@drawable/panel_background</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>

Then just call the dialog with the Theme parameter added

Dialog dialog = new Dialog(this, R.style.Theme_CustomDialog);

There fixed Motorola issues!

Yes you can try by removing border.And set requestWindowFeature(Window.FEATURE_NO_TITLE); And make sure that you are using a different class for dialog by extending it.fix the height and with for your dialog and then try

But as you said it looks different in only Motorola device.Then its difficult to tell what's going wrong. The important thing i want to share with you.I was developing application for Motorola milestone.After completing it i installed in Tablet.Then dialog size changes and its appearance too. And this was not only with custom dialog but Progress Dialog in which no properties was set, changes.Hope you got my point.Finally i want to say dialog behave sometimes unexpectedly.

Edited

Create a dialog class and its layout

public class DisplayDialog extends Dialog implements {
private ImageButton cancel,submit;
private Context context;
private ProgressDialog pd;

public DisplayDialog(Context c) {
   super(c, R.style.Theme_Dialog_Translucent);
    context = c;
}
@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setCanceledOnTouchOutside(false);
    setContentView(R.layout.dialog);
    email_id = (EditText) findViewById(R.id.email_id);
    cancel = (ImageButton) findViewById(R.id.btn_cancel);
    cancel.setOnClickListener(this);
}

}

Then from activity just make its object and call it where ever you want

DisplayDialog dd=new DisplayDialog(this);

dd.show()

The thing is that there are some troubles in Motorola styles, that override default Android styles. So, you should just override this styles once again.

As for me, I created my own theme and overrided android:windowBackground parameter. You can use your own background image, but I just took default image from Android resources. The resulting style looked like this:

<style name="Theme.GreenDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@drawable/panel_background</item>
</style>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!