android - 自定义对话框标题的布局

标签 android xml dialog title

我需要使用以下布局自定义自定义对话框的标题区域:

dialog_title.xml

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/text" 
    android:text="@string/tell_a_friend"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="8dip"
    android:paddingTop="12dip"
    android:paddingBottom="12dip"
    style="@style/bigTextWhite" />

</LinearLayout>

我正在使用扩展 Dialog 的 CustomDialog 类创建对话框。

CustomDialog dialogTellAFriend = new CustomDialog(this, Constants.TELL_A_FRIEND_DIALOG);    
dialogTellAFriend.show();

我该如何实现这一点?

最佳答案

您必须隐藏对话框标题并通过 xml 填充整个对话框。我认为这个想法最适合您。

隐藏对话框标题

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

加载对话框的布局

dialog.setContentView(R.layout.logindialog);

关于android - 自定义对话框标题的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12088783/

相关文章:

android - 如何确保至少选中 1 个复选框?

android - 使用 adb 安装发布版本的 apk 时权限会发生什么变化

android - 尝试模拟 NavController 时出错

java - Android 未知 logcat 消息 V/StudioTransport : Handling agent command 1200 for pid

java - 如何使用 Java DOM 创建 XML 节点?

php - Google API 联系人 v.3,PHP : add a contact to the group

java - 无法将 xml 转换为 java 对象

对话框中的 Android 生命周期事件

android - BottomSheetDialog/BottomSheetDialogFragment——使用哪个以及如何使用?

java - 有时 showDialog 不起作用