10

FrameLayout上にLinearLayoutコンテンツを含むSlidingDrawerを作成しようとしています。

最初はすべて問題ないようですが、画面の下部にSlidingDrawerのハンドルがあります。しかし、ハンドルを上にドラッグし始めてコンテンツが表示され始めると、ハンドルの境界線の長方形によってクリップされます。ハンドルを一番上までドラッグすると、コンテンツ全体が最終的に表示されますが、ハンドルを下にドラッグすると、コンテンツの境界線の長方形によってクリップされます。また、ハンドルが完全に上がっている場合は、ドラッグを開始するとすぐにコンテンツ全体が表示されなくなります。
画面上のハンドルの位置をクリックしてドラッグすると、コンテンツが表示されますが、ハンドルの位置を推測する必要があります。

これを引き起こしていると思われるのは、SlidingDrawerの直前のxmlファイルにSurfaceViewがあるという事実です。
xmlからビューを削除するとこの問題は解決しますが、このビューが必要です。

これがxmlです:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <!--  Removing this DrawView from here solves the problem -->
    <com.package.DrawView 
        android:id="@+id/main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />

    <SlidingDrawer  
        android:id="@+id/SlidingDrawer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:allowSingleTap="true"
        android:animateOnClick="true"
        android:handle="@+id/slideHandleButton"
        android:content="@+id/contentLayout" 
        android:padding="10dip">

        <Button
            android:id="@+id/slideHandleButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/sliding_button">
        </Button>

        <LinearLayout
            android:id="@+id/contentLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <Button 
                android:id="@+id/clearButton" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Test">
            </Button>

        </LinearLayout>

    </SlidingDrawer>

</FrameLayout>   

Java:

package com.package;

import android.app.Activity;
import android.os.Bundle;

public class SlideTest extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
    }
}

package com.package;

import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceView;

public class DrawView extends SurfaceView
{
    public DrawView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
}

編集:DrawViewがSurfaceViewではなくViewを拡張すると、この問題がなくなることに気づきました。ただし、私は専用の描画スレッドを使用しており、ドキュメント(およびLunarLanderの例)によると、専用の描画スレッドを使用すると、SurfaceViewに描画する必要があります。

どんな助けでも大歓迎です!

4

2 に答える 2

14

android:background = "#00000000"

背景色が問題でした。

于 2011-05-24T11:36:02.107 に答える
3

SurfaceViewは、ウィンドウに「穴」を切り取って、別のサーフェス(描画したサーフェス)を表示することで機能します。これが、SlidingDrawerのドロワーがクリップされる原因です。申し訳ありませんが、両方のビューを一緒に使用することはできません。

于 2011-01-08T05:44:24.080 に答える