2

ScrollViewの中身を入れるDrawerLayoutと横からスワイプしても引き出しが開けなくなりました。

アクティビティのレイアウト:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<!-- The menu_main content view -->
<FrameLayout
        android:id="@android:id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
<!-- The navigation drawer -->
<ListView
        android:name="com.gumtree.androidapp.DrawerFragment"
        android:id="@+id/drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start" />
</android.support.v4.widget.DrawerLayout>

アクティビティonCreateに、次のレイアウトを持つフラグメントを追加します。

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ImageView
            android:layout_height="160dp"
            android:layout_width="match_parent"/>

    <TextView
            android:id="@+id/headline"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="@dimen/headline_text_size"
            android:padding="@dimen/detail_text_padding"
            android:textIsSelectable="false"/>

    <TextView
            android:id="@+id/description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="@dimen/description_text_size"
            android:padding="@dimen/detail_text_padding"
            android:textIsSelectable="false"/>


</LinearLayout>
</ScrollView>

すべてが正常に機能しなくてもScrollView、横からスワイプして引き出しを開くことができます。ただし、を追加するとScrollView、機能しなくなります。

4

1 に答える 1

1

ここでの問題はFrameLayout、 のコンテンツ コンテナとして使用されるの愚かな名前の ID でしDrawerLayoutた。システム ID ( android.R.id.content) を使用したため、コンテンツ フラグメントが他のすべてのビュー (ドロワーを含む) の上に配置されました。

また、フラグメントlayoutがドロワーにオーバーラップし、-この質問に関連して-ドロワーがタッチイベントを受信するのをブロックしました。タッチ イベントはフラグメントのScrollView.

結論:システム ID (android.R.*)は、必要のない場所では使用しないでください。

私はそれがすてきできれいに見えるようにしたかった..愚かな私:)

于 2013-08-27T12:55:02.237 に答える