AlertDialog自定义标题有黑色边框 [英] AlertDialog custom title has black border
本文介绍了AlertDialog自定义标题有黑色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 AlertDialog
,我使用了自定义对话框视图。自定义标题视图的想法似乎很简单,但周围的自定义标题,我似乎无法摆脱的黑色边框。顶部,左侧和右侧有一个单一的像素边界,而底部侧具有大约5像素边界
I have an AlertDialog
that I use a custom dialog view with. The idea of the custom title view seems simple enough, but there is a black border around the custom title that I can't seem to get rid of. The top, left and right sides have a single-pixel border, while the bottom side has about a 5 pixel border.
在Java中创建对话框:
Creating the dialog in Java:
View titleView = inflater.inflate(R.layout.part_list_item, parent, false);
((TextView) titleView.findViewById(R.id.partName)).setText(titleText);
AlertDialog productDialog = new AlertDialog.Builder(getContext())
.setCustomTitle(titleView)
.setAdapter(adapter, doNothingClickListener)
.create();
自定义标题视图布局, part_list_item.xml
:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:id="@+id/partName"
android:layout_marginLeft="6dip"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
/>
我看到的:
我想看到什么:
任何想法?
推荐答案
试试这个:
LayoutInflater inflater = (LayoutInflater)yourClass.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View titleView = inflater.inflate(R.layout.custom_dialog, null);
((TextView) titleView.findViewById(R.id.partName)).setText("Your Title");
alert1.setCustomTitle(titleView);
这篇关于AlertDialog自定义标题有黑色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文