大马资讯论坛 - 马来西亚中文资讯平台

标题: [教学] android PopupWindow 圆角 rounded corners-超简单 [打印本页]

作者: 资讯王    时间: 2013-6-23 13:04
标题: [教学] android PopupWindow 圆角 rounded corners-超简单
实现圆角PopupWindow对话框。如下图:


1. 请到res/drawable建立一个新的XML档案,命名为customshape.xml
再把以下的代码贴到你的customshape.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android">
  3.     <stroke android:width="4dp" android:color="#FFFF9900" />
  4.     <padding android:left="7dp" android:top="7dp"
  5.             android:right="7dp" android:bottom="7dp" />
  6.     <corners android:radius="4dp" />
  7. </shape>
复制代码
2. 把你的popup layout LinearLayout的android:background改为customshape。
就这么简单。
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:id="@+id/popup_element"
  4.     android:layout_width="fill_parent"
  5.     android:layout_height="fill_parent"
  6.     android:orientation="vertical"
  7.     android:background="@drawable/customshape">
  8. </LinearLayout>
复制代码





欢迎光临 大马资讯论坛 - 马来西亚中文资讯平台 (http://www.freeinfo.com.my/) Powered by Discuz! X3.3