在自定义Dialog时,发现不管怎么定义View,都还是会有一条蓝色的线,如下图
其实这条蓝色的线条叫做titleDiver,去掉方法如下
try{
int dividerID=context.getResources().getIdentifier("android:id/titleDivider", null, null);
View divider=findViewById(dividerID);
divider.setBackgroundColor(Color.TRANSPARENT);
}catch(Exception e){
//上面的代码,是用来去除Holo主题的蓝色线条
e.printStackTrace();
}
把蓝色线条颜色设置为透明就OK了。加入了try和catch是考虑到如果使用Theme.Light主题时,则这一段代码会报错,所以也是为了方便代码的重用。
之后的效果如下