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

 找回密码
 注册
搜索
打印 上一主题 下一主题

[教学] android PopupWindow 圆角 rounded corners-超简单

[复制链接]
跳转到指定楼层
1#
发表于 2013-6-23 13:04:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
实现圆角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>
复制代码

手机版|大马资讯论坛  

GMT+8, 2024-4-27 21:24 , Processed in 0.057551 second(s), 15 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表