【发布时间】:2012-04-19 05:37:38
【问题描述】:
我有一个AlertDialog,我使用自定义对话框视图。自定义标题视图的想法似乎很简单,但是自定义标题周围有一个我似乎无法摆脱的黑色边框。顶部、左侧和右侧各有一个单像素边框,而底部则有大约 5 个像素的边框。
在 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 中添加阴影..?
-
@sandy 公平问题。我删除了那些位,结果是一样的,只是底部的黑色边框现在更大了。
-
在扩展 XML 时尝试将
attachToRoot设置为 true。 -
@Jacob 填充对我有用。谢谢:)
标签: android android-layout dialog android-alertdialog