Android Galaxy S 2上自定义对话框中的黑线

Android Galaxy S 2上自定义对话框中的黑线,android,dialog,Android,Dialog,我已经建立了一个自定义对话框,顶部和底部都有黑线。它们只出现在星系S2上。在其他一些设备上,它看起来还可以。我是否必须设置一个属性才能摆脱它们 这是我的密码: public class MyDialog extends Dialog { private Context context; private String title, message; private TextView titleView, messageView; private ImageVie

我已经建立了一个自定义对话框,顶部和底部都有黑线。它们只出现在星系S2上。在其他一些设备上,它看起来还可以。我是否必须设置一个属性才能摆脱它们

这是我的密码:

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);
        ...
    }

}
布局:

<?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>

经过长时间的调查,我发现三星的资源中似乎有一个失败的panel_background.9.png

解决这一黑线问题的方法是为如下对话框设置自己的背景:

<style name="CustomDialog" parent="@android:style/Theme.Dialog">
     <item name="android:windowBackground">@drawable/panel_background</item> 
</style>

@可绘制/面板背景
然后从android源代码复制panel_background.9.png或创建一个自己的!然后确保对话框在style.xml中实例化了新的主题createt


只有一个问题,现在你的对话将失去“三星对话风格”。这意味着该角可能不同于应用程序中的其他默认对话框…

我在SGS II上的所有自定义对话框上也得到了相同的结果。