2016-02-15 50 views
-2

我正在使用自定義對話框,我想刪除這條藍線。我怎樣才能做到這一點?安卓提醒對話框 - 無法刪除默認藍線

我試圖alert.requestWindowFeature(Window.FEATURE_NO_TITLE);和其他一些方法,但沒有影響

下面的代碼無法正常工作!

int divierId = alert.getContext().getResources() 
       .getIdentifier("android:id/titleDivider", null, null); 
View divider = alert.findViewById(divierId); 
divider.setBackgroundColor(getResources().getColor(R.color.creamcolor)); 

this image

+1

的可能的複製[?如何隱藏藍線標題divder alertdialog(http://stackoverflow.com/questions/20853970/ how-to-hide-the-blue-line-title-divider-alertdialog) – Strider

回答

0

,在警告對話框中藍線是標題和消息 之間的分隔,這將改變分隔顏色,您可以設置Color.Transperent隱藏它

int divierId = alert.getContext().getResources() 
        .getIdentifier("android:id/titleDivider", null, null); 
    View divider = alert.findViewById(divierId); 
    divider.setBackgroundColor(getResources().getColor(R.color.creamcolor)); 
+0

請解釋你的答案 – CaptJak

0

我得到了解決以引用alertdialog的titledivider使用下面的代碼來改變它的顏色。希望這有助於某人。

int divierId = dialog.getContext().getResources() 
       .getIdentifier("android:id/titleDivider", null, null); 
View divider = dialog.findViewById(divierId); 
divider.setBackgroundColor(getResources().getColor(R.color.white)); 
0

爲了隱藏默認的藍線:

Dialog dialog = getDialog(); 
    if (dialog != null) { 
     final int dividerId = dialog.getContext().getResources() 
       .getIdentifier("android:id/titleDivider", null, null); 
     View divider = dialog.findViewById(dividerId); 
     if (divider != null) { 
      divider.setBackground(null); 
     } 
    }