popUpWindow 动画无法超出窗体的解决方案

popupWindow 做动画时,当要求有一个放大动画时,动画无法超出窗体,给人的感觉是只有内容在放大,窗体不动。

这是由于窗口大小固定的原因,解决方案是加大popUpwindow的 大小。

一个比较省事儿的方案是,直接把popupwindow窗体设为全屏和透明。这样你就可以任意玩了。这种方案的缺点是 弹窗的位置无法用自带的方法设置。

另外点击窗口外弹窗消失也没法实现了。所以最好的解决方案是,弹窗的大小稍微大于view的大小。

目前的处理办法是,在做popview布局时在外面套一个空布局,然后在内层布局中设置一定的margin值。这样也不会屏蔽掉点击外部退出弹窗的效果。代码如下:

<?xml version="1.0" encoding="utf-8"?>
//套一个空布局
<com.zhy.autolayout.AutoRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <com.zhy.autolayout.AutoLinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"//设置margin值,由于我的效果是贴着右上角弹出来,所以右面和上面margin值设置小一点,或者不设置(紧贴)
        android:layout_marginRight="2dp"
        android:layout_marginTop="2dp"
        android:background="@drawable/pop_bg_shape"
        android:orientation="vertical">
        <TextView
            android:id="@+id/tv_createFolder"
            android:layout_width="224px"
            android:layout_height="68px"
            android:gravity="center"
            android:text="新建文件夹"
            android:textColor="@color/button_textColor"
            android:textSize="24px" />

 

posted @ 2016-08-01 17:55  epmouse  阅读(566)  评论(0编辑  收藏  举报