Java 将android对话框标题换行到多行
有没有办法将Android自定义对话框中的标题包装为多行?不需要做一个AlertDialogJava 将android对话框标题换行到多行,java,android,dialog,google-api,Java,Android,Dialog,Google Api,有没有办法将Android自定义对话框中的标题包装为多行?不需要做一个AlertDialog dialog.setContentView(R.layout.custom_dialog); dialog.setTitle(itemTitle); “itemTitle”有时太长,只显示一半的文本。使用popupwindow 使用弹出窗口 您可以将文本视图放在用于对话框的任何父布局的开头: <TextView android:id="@+id/mydialogtitle" an
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle(itemTitle);
“itemTitle”有时太长,只显示一半的文本。使用popupwindow
使用弹出窗口
您可以将
文本视图
放在用于对话框的任何父布局的开头:
<TextView
android:id="@+id/mydialogtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:background="@color/black"
android:textSize="20sp" />
您可以将
TextView
放在用于对话框的任何父布局的开头:
<TextView
android:id="@+id/mydialogtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:background="@color/black"
android:textSize="20sp" />
答案抄袭自
可以使对话框标题多行:
TextView title = (TextView) dialog.findViewById(android.R.id.title);
title.setSingleLine(false);
答案抄袭自
可以使对话框标题多行:
TextView title = (TextView) dialog.findViewById(android.R.id.title);
title.setSingleLine(false);
你可以使用一个完全定制的视图来膨胀标题,我认为这是最简单的方法。大概是这样的:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String infService = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(infService);
View titleView = inflater.inflate(R.layout.dialog_title, null);
builder.setCustomTitle(titleView);
其中R.layout.dialog\u标题可以是多行文本视图,也可以是任何您想要的内容。您可以使用完全自定义的视图来膨胀标题,我认为这是最简单的方法。大概是这样的:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String infService = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(infService);
View titleView = inflater.inflate(R.layout.dialog_title, null);
builder.setCustomTitle(titleView);
其中R.layout.dialog\u title可以是包含多行的文本视图,也可以是您想要的任何内容。正如我前面所说的“有没有一种方法可以将Android自定义对话框中的标题包装为多行?而不必制作AlertDialog?”因此,不,我没有使用AlertDialog。我使用的是自定义对话框。您扩展了dialog类了吗?正如我前面所说的“有没有一种方法可以将Android自定义对话框中的标题包装为多行?而不必制作AlertDialog?”因此,不,我没有使用AlertDialog。我正在使用自定义对话框。您是否扩展了dialog类?