Wirack
Wirack

Reputation: 81

Android DialogFragment - weird transparent box

I have been implementing a very sweet camera dialog fragment, following the Android and Vogella guides for it.

However, I get a transparent box in the dialog box I make (had to take the picture with a phone)

And I think it has something to do with not redrawing the DialogFragment, as when I take a screenshot from the tablet it looks as it should like this:

Do you have any idea how to fix this, as I can't figure out why.

Xml here:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/fragment_background"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="50dp">

<FrameLayout
    android:id="@+id/camera_preview"
    android:layout_width="500dp"
    android:layout_height="500dp"
    android:layout_weight="1">
</FrameLayout>

<LinearLayout
      android:orientation="horizontal"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_alignParentBottom = "true">

      <GToggleButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/color_effects"
          android:drawableTop="@drawable/bw_icon" />

      <GButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/button_capture"
          android:drawableTop="@drawable/cam" />

      <GButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/switch_cam"
          android:drawableTop="@drawable/cam_facing" />

  </LinearLayout>

</LinearLayout>

Also in the onResume method I do:

    Window window = getDialog().getWindow();
    window.setLayout(AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.FILL_PARENT);

    window.setGravity(Gravity.CENTER);

But when I set both width and height to FIll_PARENT it does not show the transparent box, but I want a dialogbox that does not fill the whole parent UI.

Upvotes: 0

Views: 291

Answers (1)

Wirack
Wirack

Reputation: 81

I tried to run the program on another tablet, and found that it was a tablet specific or API specific issue.

The problem was with Samsung GALAXY Tab 10.1 or API 15

It works fine on Samsung Galaxy Tab 2 but not Samsung Galaxy Tab 3, more debugging is needed.

Upvotes: 1

Related Questions