我将此代码用于自定义对话框标题XML-layout
public class UtilityDialog extends Dialog
{
onCreate(Bundle savedInstanceState)
{
....
....
....
getWindow().requestFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.dialog_title);
setContentView(content);
}
}
它有效但标题的高度太小而且它不包含任何UI元素 R.layout.dialog_title
R.layout.dialog_title - >
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="65dip"
android:padding="2dip"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/logoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Cellalert" />
</RelativeLayout>