问题
I have created Custom Dialog for my application. While i run that application in normal Samsung Galary Ace then it shows proper in that device but while i am going to run that app in Motorola Atrix then the Custom Dialog Box not seen proper with the border. . . Please see the Image of Motorola Atrix Emulator with my Custom Dialog in it.
Should i have to remove the border of the custom dialog or what else i have to do to see only my custom dialog in any device ? If i have to remove the border from the custom dialog then let me know how ??
Thanks.
回答1:
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!
回答2:
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()
回答3:
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>
来源:https://stackoverflow.com/questions/8488128/why-i-am-not-able-to-see-proper-custom-dialog-box-in-motorola-atrix-emulator