Android PopupWindow全屏背景色

时间:2015-08-03 20:47:55

标签: android popupwindow

我正在尝试在显示PopupWindow时显示全屏悬停背景:(见下图以查看预期的最终结果)

enter image description here

不幸的是,这就是我得到的:(见下图)

enter image description here

遵循代码:

../ TodayFragment.java (弹出活动)

...    
popup = new PopupWindow(
            popupView,
            RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT,
            true
    );
    popup.setOutsideTouchable(true);
    popup.setBackgroundDrawable(new BitmapDrawable());
    popup.showAsDropDown((RelativeLayout) getView().findViewById(R.id.fragment_today), -400, 10);
...

../ layout / activity_popup.xml (弹出式布局)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/popup_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#4c666666"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<ImageButton
    android:id="@+id/button_smile_sad"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:background="@null"
    android:src="@drawable/smile_sad" />

<ImageButton
    android:id="@+id/button_smile_normal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_toRightOf="@id/button_smile_sad"
    android:background="@null"
    android:src="@drawable/smile_normal" />

<ImageButton
    android:id="@+id/button_smile_happy"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_toRightOf="@id/button_smile_normal"
    android:background="@null"
    android:src="@drawable/smile_happy" />
</RelativeLayout>

../ layout / fragment_today.xml (父级布局)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_today"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.p_alex.happinesstracker.MainActivity">

<ImageView
    android:id="@+id/happiness_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />

<com.melnykov.fab.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:src="@drawable/ic_add_white_24dp"
    fab:fab_colorNormal="@color/colorDark"
    fab:fab_colorPressed="@color/colorPrimary"
    fab:fab_colorRipple="@color/happy" />
</RelativeLayout>

如何在显示弹出内容时显示完整的悬停背景? THX。

0 个答案:

没有答案