我有一个AlertDialog
,我使用自定义对话框视图。自定义标题视图的想法似乎很简单,但自定义标题周围有一个黑色边框,我似乎无法摆脱它。顶部,左侧和右侧具有单像素边框,而底部具有约5个像素边框。AlertDialog自定义标题有黑色边框
使用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"
/>
我看到:
我希望看到的:
任何想法?
是相对布局和阴影填充在TextView的必要..? – ngesh 2012-04-19 05:40:32
@sandy公平的问题。我删除了这些位,结果是相同的,只是底部的黑色边框现在变大了。 – 2012-04-19 05:43:53
尝试在膨胀XML时将'attachToRoot'设置为true。 – dreamtale 2012-04-19 05:55:28