笔记78--Popupwindow实现类似AlertDialog半透明效果
2014-09-19 00:06
423 查看
Dialog和Popupwindow区别详见:笔记41
一、实现原理
设置PopupWindow加载的布局背景变灰。
二、实现步骤
1、先将PopupWindow全屏显示。
2、设置布局的背景颜色
三、代码
1、设置Popupwindow全屏
<pre name="code" class="java">View viewSearch=LayoutInflater.from(this).inflate(R.layout.why_search_result, null);
result_dg=new PopupWindow(viewSearch, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
2、设置布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a0000000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:background="#ffffff"
android:orientation="vertical" >
<ListView
android:id="@+id/why_recLV"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="@null"
android:fastScrollEnabled="true"
android:scrollbars="none"
android:scrollingCache="false" >
</ListView>
</LinearLayout>
</RelativeLayout>最主要是设置最外层布局背景色为:
四、其他问题
1、设置back键关闭popupwindow
<pre name="code" class="java">// 加上下面两行可以用back键关闭popupwindow,否则必须调用dismiss();
ColorDrawable dw = new ColorDrawable(-00000);
rec_dg.setBackgroundDrawable(dw);
rec_dg.update();
2、如果popupwindow中有EditText
一、实现原理
设置PopupWindow加载的布局背景变灰。
二、实现步骤
1、先将PopupWindow全屏显示。
2、设置布局的背景颜色
三、代码
1、设置Popupwindow全屏
<pre name="code" class="java">View viewSearch=LayoutInflater.from(this).inflate(R.layout.why_search_result, null);
result_dg=new PopupWindow(viewSearch, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
2、设置布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a0000000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:background="#ffffff"
android:orientation="vertical" >
<ListView
android:id="@+id/why_recLV"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="@null"
android:fastScrollEnabled="true"
android:scrollbars="none"
android:scrollingCache="false" >
</ListView>
</LinearLayout>
</RelativeLayout>最主要是设置最外层布局背景色为:
#a0000000
四、其他问题
1、设置back键关闭popupwindow
<pre name="code" class="java">// 加上下面两行可以用back键关闭popupwindow,否则必须调用dismiss();
ColorDrawable dw = new ColorDrawable(-00000);
rec_dg.setBackgroundDrawable(dw);
rec_dg.update();
2、如果popupwindow中有EditText
相关文章推荐
- Android 必知必会 - DialogFragment 实现类似 PopupWindow 效果
- android实现类似toast效果的圆角dialog警告框
- PopupWindow 实现 弹出后 其余部分变灰(类似dialog)
- Android安卓用Dialog对话框简单并且完美实现popupWindow底部弹出效果,有动画效果
- CSS实现半透明效果实现及兼容性笔记
- Android AlertDialog实现半透明的弹窗
- React-Native学习笔记之:Modal实现覆盖效果(类似安卓中PopuWindow)
- 学习笔记--实现类似酷狗音乐歌词的效果
- Android编程实现popupwindow弹出后屏幕背景变成半透明效果
- 实现类似toast效果的圆角dialog警告框
- jQuery实现弹窗居中效果类似alert()
- 实现js的类似alert效果的函数
- 如何实现当一个应用调用另一个应用的某个activity的时候,让这个activity类似dialog的效果,但是这个应用单独运行的时候还是铺满屏幕的效果
- popupWindow 实现悬浮半透明效果
- 实现popupWindow类似效果的activity
- 笔记,GridView点击添加背景,类似checkbox效果的实现
- 实现类似toast效果的圆角dialog警告框
- Dom利用javascript实现模拟弹出对话框效果的代码,类似JQuery中的dialog!
- Android学习记录(八) alertDialog和popupwindow简单实现
- 自定义uiview 实现类似alertview的效果