Skip to content

Instantly share code, notes, and snippets.

@rahulkhatri19
Created February 18, 2020 04:46
Show Gist options
  • Save rahulkhatri19/907691612a6465a1a502c4ea7f976487 to your computer and use it in GitHub Desktop.
Save rahulkhatri19/907691612a6465a1a502c4ea7f976487 to your computer and use it in GitHub Desktop.
// Customizing title of Alertdilaog.
val builder = AlertDialog.Builder(this, R.style.CustomAlertDialog)
val tvTitle= TextView(this)
tvTitle.text = "Title of Alert Dialog!"
tvTitle.textSize = this.resources.getDimension(R.dimen.snack_bar_text_size)
builder.setCustomTitle(tvTitle)
// Cuatom default button
<style name="CustomAlertDialog" parent="@android:style/Theme.Dialog"> // for white : Theme.AppCompat.Light.Dialog.Alert
<item name="android:textSize">@dimen/snack_bar_text_size</item>
</style>
// try this too
<item name="android:bottomBright">@color/white</item>
<item name="android:bottomDark">@color/white</item>
<item name="android:bottomMedium">@color/white</item>
<item name="android:textSize">10</item>
<item name="android:centerBright">@color/white</item>
<item name="android:centerDark">@color/white</item>
<item name="android:centerMedium">@color/white</item>
<item name="android:fullBright">@color/orange</item>
<item name="android:fullDark">@color/orange</item>
<item name="android:topBright">@color/blue</item>
<item name="android:topDark">@color/blue</item>
// message
AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Hello world").show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(40);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment