問題描述
當我運行此代碼時,會顯示警報對話框,但對話框周圍有一個白色邊框,而且邊框有點圓.我不想要這個白色邊框,我想要真正的角為 90 度.我希望你明白我在做什么.
When I run this code the alert dialog is shown but there is one white border around the dialog and also the borders are little round. I do not want this white border and I want to have real corners with angle of 90. I hope you understand what I am trying to do.
AlertDialog.Builder ad = new AlertDialog.Builder(this);
Button bbb=new Button(MvcnContactList.this);
ad.setView(bbb);
alertDialog = ad.create();
alertDialog.show();
有什么方法可以設置警報對話框的樣式,但不能設置文本顏色或文本大小或類似的樣式...我想設置警報對話框的邊框樣式,因此僅設置一個主題也許可以解決此問題.但我不知道要覆蓋哪些屬性.
Is there any way to style the alert dialog but not the text color or text size or something similar... I want to style the borders of the alert dialog, so setting just a theme maybe it is solution to this problem. But I do not know what properties to override.
謝謝,
例如,這種樣式將 textColor 覆蓋為 00FF00 ,這很酷,但是我應該覆蓋哪個屬性以使角不圓并移除那個白色的鉆孔
For example this style override the textColor to 00FF00 , and that is cool, but which property should I override to make the corners not round and tho remove that white boreder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AlertDialogCustom" parent="@android:style/AlertDialog">
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
<item name="android:textSize">10sp</item>
</style>
</resources>
推薦答案
我找到了使用包裝器的解決方案,您可以在其中為當前上下文中的任何內容設置主題(樣式).我將 R.style.MyTheme 設置為警報對話框的樣式,并根據自己的喜好定制了該視圖.
I found solution with the wrapper, where you can set a theme (style) to anything in the current context. I set R.style.MyTheme as style to my alert dialog and I customized that view to my own taste.
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.MyTheme );
AlertDialog.Builder builder= new AlertDialog.Builder( ctw );
這篇關于更改 AlertDialog 的樣式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!