loading

Android - DrawerLayout 抽屉布局没有反应

<androidx.drawerlayout.widget.DrawerLayout
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <!-- 主视图的内容,非抽屉展示的内容 -->
  <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
      android:id="@+id/weather_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:overScrollMode="never"
      android:scrollbars="none">

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

        <include layout="@layout/title" />
        <include layout="@layout/now" />
        <include layout="@layout/forecast" />
        <include layout="@layout/aqi" />
        <include layout="@layout/suggestion" />
      </LinearLayout>
    </ScrollView>
  </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

  <!-- 抽屉视图的内容 -->
  <androidx.fragment.app.FragmentContainerView
    android:id="@+id/choose_area_fragment"
    android:name="com.coolweather.android.ChooseAreaFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start" />

</androidx.drawerlayout.widget.DrawerLayout>

抽屉布局应该只能有两个子布局,第一个是主视图,第二个是抽屉视图的内容。并且,抽屉视图的内容的属性要有android:layout_gravity="start"或者android:layout_gravity="left"。如果 AS(Android Studio)没有提示你这个属性,直接添加上就行。

posted @ 2022-12-17 00:11  Himmelbleu  阅读(25)  评论(0编辑  收藏  举报