当前位置: 代码迷 >> Android >> 求教怎么实现类似 windows 上置顶的非模态对话框效果
  详细解决方案

求教怎么实现类似 windows 上置顶的非模态对话框效果

热度:2   发布时间:2016-05-01 09:49:32.0
求教如何实现类似 windows 上置顶的非模态对话框效果
希望可以实现如下功能,求思路或者方法。。

类似于置顶的浮动窗口,但希望只是一个 app 内部的,不希望是全局的。这个浮动窗口里可以自己设置 layout,浮动窗口本身也可以自由移动.

如图,红色框部分是一个置顶的浮动窗口,按住M部分时,可以随意拖动,右边有3个按钮1,2,3 也可以随意点击。
同时,也可以对后面的activity上的控件进行操作,点击A1,A2按钮也是可以响应的,并且浮动窗口不消失。

思路1, 使用 Dialog, Dialog显示的时候,不知道如何可以让后面Activity 上的控件也响应操作,并且Dialog不消失
思路2, 使用popupWindow,  popupWindow似乎是模态的,窗口跳出的时候,后面的控件就不响应了。
思路3, 添加一个View, 但是不知道如何才能实现,在View 上面继续添加控件或者layout 


求教,谢谢

layout 对话框 android

------解决方案--------------------
同一界面用多个View吧,方便,用RelativeLayout的方式。再处理手指拖到

test_float.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff" >
    <Button 
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:text="测试"
        />

</LinearLayout>


float_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"  
  android:gravity="center"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
<RelativeLayout 
    android:id="@+id/rlfloatView"
        android:layout_width="200px"
        android:background="#F42B2B"
        android:layout_gravity="center"
        android:layout_height="200px" >
        
        <Button 
  相关解决方案