नीचे कोड का उपयोग करें:
final Dialog mailDialog = new Dialog(MainActivity.this);
mailDialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_box);
और नीचे के रूप में drawable फ़ोल्डर में एक कस्टम संवाद बॉक्स एक्सएमएल बनाने के लिए:
dialog_box.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<gradient
android:angle="-90"
android:centerColor="#660D1E4A"
android:endColor="#66011444"
android:startColor="#66505E7F"
android:type="linear"
/>
<stroke
android:dashGap="0dp"
android:dashWidth="0dp"
android:width="1dp"
android:color="#ffffffff" />
</shape>
आशा यह आप में मदद करता है।
int titleLayoutId = dialog.getContext().getResources().
getIdentifier("topPanel", "id", "android");
LinearLayout layout = (LinearLayout) dialog.findViewById(titleLayoutId);
if (layout != null) {
layout.setBackgroundColor(yourColor);
}
यह एक कस्टम लेआउट बनाने के लिए की आवश्यकता समाप्त:
यह आपके लिए उपयोगी है: http://stackoverflow.com/a/15285514/1318946 –
@PratikButani। मुझे लगता है कि उसने पृष्ठभूमि के लिए पूछा .. शीर्षक के टेक्स्ट रंग नहीं .. – Abhi