width
override fun onStart() {
super.onStart()
dialog?.window?.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
}
Margin
val back = ColorDrawable(Color.TRANSPARENT)
val inset = InsetDrawable(back, 40)
dialog!!.window!!.setBackgroundDrawable(inset)
or
android:background="@drawable/dialog_background"
margin by xml
`dialog_background`
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/dialog_background_gradient"
android:insetLeft="40dp"
android:insetRight="40dp" />
`dialog_background_gradient`
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:centerColor="#FFFFFF"
android:endColor="#000000"
android:startColor="#FFFFFF"
android:type="linear"
android:useLevel="true" />
<corners android:radius="5dp" />
</shape>
Html

https://developer.android.com/guide/topics/resources/string-resource#StylingWithHTML

not work:
getHtmlString(
getString(R.string.dialog_sub_title,
getAmount(coin),
getTask(task)))
<string name="dialog_sub_title">
Download the app1 <font color="#FF6237">%1$s</font>,\n
Download the app2 <font color="#FF6237">%2$s</font>
</string>
work well:
add CDATA: https://developer.android.com/reference/org/w3c/dom/CDATASection
add <b></b>: blod
getHtmlString(
getString(R.string.dialog_sub_title,
getAmount(coin),
getTask(task)))
<string name="dialog_sub_title">
<![CDATA[
Download the app1 <font color="#FF6237"><b>%1$s</b></font>,\n
Download the app2 <font color="#FF6237">%2$s</font>
]]>
</string>