
如何更改AlertDialog中的textcolor?
<item name="android:textColor">@color/black_text</item>
Run Code Online (Sandbox Code Playgroud)
这仅更改标题颜色.
ad = new AlertDialog.Builder((new ContextThemeWrapper(context, R.style.DialogTheme)));
ad.setTitle(R.string.my_activ_remove_title_dialog);
ad.setPositiveButton(R.string.my_activ_remove_dialog, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
content.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, content.size());
}
});
ad.setNegativeButton(R.string.my_activ_cancel_remove_dialog, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
}
});
Run Code Online (Sandbox Code Playgroud)
我在做什么:我正在创建一个自定义警报对话框
我想做什么:以及下面的代码,如何更改对话框中的操作按钮的颜色(正面和负面)
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialog_signin, null))
// Add action buttons
.setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface …Run Code Online (Sandbox Code Playgroud) 我有一个AlertDialog和它的消息显示,但文本的颜色是白色.它与背景融为一体.我试过改变主题,但它不起作用.如何更改消息的颜色?
相关代码:
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(MainActivityGame.this);
builder.setTitle("Name");
builder.setMessage("Are you ");
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Submit default name, go home
boolean isInserted = myDb.insertData(defaultName, triesTaken, difficultyText);
if (isInserted) {
Toast.makeText(MainActivityGame.this, "Your name was submitted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivityGame.this, "Error, your name wasn't submitted\n Have you entered a default name?\n Go to Settings/Default Name to set it up", Toast.LENGTH_SHORT).show();
}
Intent intent = new Intent(MainActivityGame.this, MainActivity.class);
startActivity(intent);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试更改对话框中的文本颜色,最常见的是AlertDialog.我在这些页面上尝试了所有解决方案:
AlertDialog样式 - 如何更改标题,消息等的样式(颜色)
如何更改AlertDialog标题的颜色以及其下方的线条颜色
大多数解决方案的工作低于5.0但高于它,它们似乎没有任何影响.我应该为5.0+更改哪些不同的属性?
我的应用程序的父主题是"Theme.AppCompat.Light.NoActionBar"
如何在AlertDialog.Builder AppCompat中更改Items的颜色?
我想将textColor项目(照片,gallary)设置为其他任何项目.
这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
builder.setTitle(getResources().getString(R.string.choose_image_source));
builder.setItems(new CharSequence[]{getResources()
.getString(R.string.photo), getResources()
.getString(R.string.camera)}, new DialogInterface.OnClickListener() {
Run Code Online (Sandbox Code Playgroud)
...
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#000000</item><!-- buttons OK cancel-->
<item name="android:textColorPrimary">#696969</item><!--text in message-->
<item name="android:background">#f0a400</item> <!-- all bg-->
</style>
<style name="MyTitleTextStyle">
<item name="android:textColor">#000000</item><!-- title color-->
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我正在尝试通过样式更改警报对话框中消息的字体大小,但无法使其正常工作。有很多答案描述了如何执行此操作,但是我发现它们几乎都是以编程方式执行的。我想只使用一次样式,而不是使用每个新的alertdialog。
到目前为止,我所做的是:
在其中,\AndroidSDK\platforms\android-23\data\res\layout\alert_dialog.xml我看到了显示消息的TextView:
<TextView android:id="@+id/message"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip" />
Run Code Online (Sandbox Code Playgroud)
在\AndroidSDK\platforms\android-23\data\res\values\themes.xml我看到的textAppearanceMedium属性值是@style/TextAppearance.Medium。
我创建了以下父样式为的样式TextAppearance.AppCompat.Medium。然后将该样式应用于android:textAppearanceMediumAlertDialog样式的属性,如下所示:
<style name="Theme.My" parent="Theme.AppCompat.Light.NoActionBar.FullScreen">
<item name="android:alertDialogTheme">@style/Theme.My.AlertDialog</item>
</style>
<style name="Theme.My.AlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textAppearanceMedium">@style/MyTextAppearanceMedium</item>
</style>
<style name="MyTextAppearanceMedium" parent="TextAppearance.AppCompat.Medium">
<item name="android:textSize">24sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
...但是字体大小不会改变。怎么了?
我正在使用AppCompat支持库,最低SDK 16,目标SDK 23。
谢谢。
嗨我正在使用自定义主题来自定义我的警报对话框.我的问题是,当我将背景颜色设置为任何颜色时,我的文本变得不可见.这是我的代码
<style name="CustomDialogFragment" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@color/black</item>
<item name="textColorAlertDialogListItem">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,并提前感谢
android android-alertdialog android-dialogfragment android-styles android-background