Black line in custom dialog on Galaxy S 2
I've built a custom dialog and there are black lines at the top and bottom. They only appear on the Galaxy S2. On some other devices it looks ok. Is there an attribute I have to set to get rid of them?
Here is my code:
public class MyDialog extends Dialog {
private Context context;
private String title, message;
private TextView titleView, messageView;
private ImageView icon;
private int iconRes;
private boolean spin;
public MyDialog(Context context, int icon, boolean spin, String title, String message) {
...
}
private void init() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(R.layout.my_dialog);
...
}
}
Layout:
<?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:minWidth="300dip" style="@style/basic" android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/titlebar_bg"
android:orientation="horizontal" android:gravity="center_vertical"
android:paddingBottom="5sp">
<ImageView android:src="@drawable/info" android:id="@+id/dialogIcon"
android:layout_height="32sp" android:layout_width="32sp" />
<TextView android:id="@+id/titleText" android:text="Title"
android:textSize="20sp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/darkgrey"
android:layout_marginLeft="5sp" />
</LinearLayout>
<TextView android:layout开发者_如何学运维_width="wrap_content"
android:layout_height="wrap_content" android:paddingTop="5sp"
android:textColor="#000" android:id="@+id/messageText" android:text="Message" />
</LinearLayout>
After quite a long time investigating this issue, I found out, that Samsung seems to have a failing panel_background.9.png in their resources...
A workaround to get ride of this black lines is to set your own background for Dialogs like this:
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/panel_background</item>
</style>
Then Copy the panel_background.9.png from the android source or create an own one! Then make sure your Dialog is instantiate with the new Theme createt in your style.xml...
There is just one problem, now your dialog will loose the "Samsung-Dialog-Style". Which means the corner may differ from other default-dialogs in your app...
精彩评论