如何确定SlidingDrawer手柄的屏幕位置/高度?
大家好,
我正在使用带有自定义 SurfaceView 的 SlidingDrawer 并遇到了问题。 问题是SurfaceView不知道剩余的视图区域 当SlidingDrawer的手柄被上下拖动时。
有没有办法根据手柄当前高度设置 SurfaceView 高度?
布局 XML:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<and.dev.test.CustomSurfaceView android:id="@+id/flock"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
<SlidingDrawer android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/drawer"
android:handle="@+id/handle" android:content="@+id/content"
android:layout_gravity="fill">
<LinearLayout android:id="@id/handle"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal"
android:background="#FFFFFFFF">
<TextView android:background="@drawable/bird_blue"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@id/content"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
</SlidingDrawer> </FrameLayout>
HI Guys,
I'm using SlidingDrawer with a custom SurfaceView and ran into a problem.
The problem is that the SurfaceView doesn't know about the remaining view area
when the handle of the SlidingDrawer is being drag up and down.
Is there a way to set my SurfaceView height base on where the handle current height?
Layout XML:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<and.dev.test.CustomSurfaceView android:id="@+id/flock"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
<SlidingDrawer android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/drawer"
android:handle="@+id/handle" android:content="@+id/content"
android:layout_gravity="fill">
<LinearLayout android:id="@id/handle"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal"
android:background="#FFFFFFFF">
<TextView android:background="@drawable/bird_blue"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@id/content"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
</SlidingDrawer> </FrameLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SlidingDrawer
只能用作布局上的叠加层。这几乎意味着您只能将其放入FrameLayout
或RelativeLayout
中。只需将自定义
SurfaceView
和SlidingDrawer
放入 XML 中的FrameLayout
中即可,无需担心调整高度大小或其他任何问题。希望有帮助
SlidingDrawer
can only be used as an overlay over layouts. That pretty much means that you can only put it inside aFrameLayout
or aRelativeLayout
.Just put your custom
SurfaceView
andSlidingDrawer
in aFrameLayout
in your XML and you'll be fine and wont have to worry about resizing heights or anything.Hope that helps