Kent Andersen
Kent Andersen

Reputation: 2201

Nexus 7 layout issue with sliding drawer

Right now in my app I have a sliding drawer on the the right side of the screen that a user can pull to the left to see more details. The problem lies with the "Handle" of the sliding drawer. On ALL devices it looks great and is where it should be. However, on the Nexus 7 there is extra space to the right.

The brown space shouldn't be there int he middle

Here is my layout code. Please help identify why Nexus 7 is different. Thanks.

 <com.app.android.apps.app.views.DragContentSlidingDrawer
                   android:id="@+id/drawer"
                   android:layout_width="match_parent"
                   android:layout_height="fill_parent"
                   ancestry:orientation="horizontal"
                   android:layout_alignParentRight="true"
                   ancestry:handle="@+id/panel_slider2"
                   ancestry:content="@+id/panel_frame"
                   ancestry:allowSingleTap="false" >

    <ImageView android:layout_width="wrap_content"
               android:layout_height="fill_parent"
               android:id="@+id/panel_slider2"
               android:src="@drawable/panel_handle"
               android:scaleType="fitXY"
               android:layout_alignParentRight="true"

            />


    <RelativeLayout android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="right"
                    android:id="@+id/panel_frame">

        <LinearLayout android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:gravity="right"
                      android:layout_alignParentBottom="true"
                      android:layout_alignParentRight="true"
                      android:id="@+id/panel_layout">

            <FrameLayout android:layout_height="fill_parent"
                         android:layout_width="fill_parent"
                         android:id="@+id/panel_layout_holder"
                         android:background="@color/background"/>

        </LinearLayout>

    </RelativeLayout>

</com.app.android.apps.app.views.DragContentSlidingDrawer>

Upvotes: 1

Views: 283

Answers (2)

Rohit
Rohit

Reputation: 490

It seems like you have done mistake with XML code. Try the following corrections:

<com.app.android.apps.app.views.DragContentSlidingDrawer
                   android:id="@+id/drawer"
                   android:layout_width="**fill_parent**"
                   android:layout_height="fill_parent"
                   ancestry:orientation="horizontal"
                   android:layout_alignParentRight="true"
                   ancestry:handle="@+id/panel_slider2"
                   ancestry:content="@+id/panel_frame"
                   ancestry:allowSingleTap="false" >

Upvotes: 1

Kent Andersen
Kent Andersen

Reputation: 2201

It looks like I didn't post quite enough to solve this problem. The code that is drawing the handle is an overridden method of "dispatchDraw" from "Viewgroup". To solve the problem, in that method, I detect the handles position and fix it using the code below.

 if (mHandle.getLeft() == 0) {
        handle.offsetLeftAndRight(10);
    }

It still doesn't quite make sense why this would only happen on the Nexus 7, but in the end, this fixes it.

Upvotes: 1

Related Questions