今天做一个android 对话框,遇到一个奇怪的问题,设置对话框的圆角的时候,写了个 top_radius.xml 文件,本意是要设置上面两个角是圆角,下面两个角保持直角,:
<span style="font-family:FangSong_GB2312;font-size:14px;"><!-- 矩形 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- 实心 -->
<solid android:color="#56565b" />
<!-- 圆角 -->
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape></span>
奇怪的是无论我怎么设置 android:bottomLeftRadius 和 android:bottomRightRadius,对话框的圆角都是按照 android:topLeftRadius 和 android:topRightRadius设置的参数来变化的。在graphical layout中看起来如下图所示,矩形四个角始终都为圆角。
考虑到graphical layout上显示的并不一定与真实机上的一致,还是在真实机上直接运行了。结果真是欲哭无泪,手机上显示完全正常。看来eclipse上提供的UI预览真的不太可靠啊。