Android 带滑动抽屉的Nexus 7布局问题
现在,在我的应用程序中,我在屏幕右侧有一个滑动抽屉,用户可以将其向左拉以查看更多细节。问题在于滑动抽屉的“把手”。在所有设备上,它看起来都很棒,而且是它应该达到的位置。然而,在Nexus7的右边有额外的空间 这是我的布局代码。请帮助确定Nexus 7的不同之处。谢谢Android 带滑动抽屉的Nexus 7布局问题,android,android-layout,slidingdrawer,nexus-7,Android,Android Layout,Slidingdrawer,Nexus 7,现在,在我的应用程序中,我在屏幕右侧有一个滑动抽屉,用户可以将其向左拉以查看更多细节。问题在于滑动抽屉的“把手”。在所有设备上,它看起来都很棒,而且是它应该达到的位置。然而,在Nexus7的右边有额外的空间 这是我的布局代码。请帮助确定Nexus 7的不同之处。谢谢 <com.app.android.apps.app.views.DragContentSlidingDrawer android:id="@+id/drawer"
<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>
看起来我没有发布足够的帖子来解决这个问题。绘制句柄的代码是从“Viewgroup”重写的“dispatchDraw”方法。为了解决这个问题,在该方法中,我检测手柄位置并使用下面的代码修复它
if (mHandle.getLeft() == 0) {
handle.offsetLeftAndRight(10);
}
为什么只在Nexus 7上出现这种情况仍然不太清楚,但最终,这解决了它。似乎您在XML代码方面犯了错误。请尝试以下更正:
<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" >
您是否也可以发布用于加载此布局的代码?我也不完全清楚截图是什么。中间的深棕色竖条就是你提到的把手吗?dokkaebi,这张图片是滑动抽屉的截图。深棕色部分是不需要的空间。事实上,我找到了解决问题的方法。我会发布一个答案。