12.3是滑動選單,按照書上的代碼,app運行就是滑動選單覆寫了toolbar控制元件,無法碩訓和拉出。
gitee地址
uj5u.com熱心網友回復:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:gravity="start"
android:text="This is menu"
android:textSize="30sp" />
</androidx.drawerlayout.widget.DrawerLayout>
你這個TextView把FrameLayout覆寫了呀。你把TextView刪了試試
uj5u.com熱心網友回復:
@不會寫代碼的猴子書上就是這么寫的,是作者寫錯了?
uj5u.com熱心網友回復:
不行,還是沒有滾動選單。
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
這就是代碼執行后的結果,不知道是不是你想要的uj5u.com熱心網友回復:
不是我要的效果,drawerlayout的效果是從側邊拉出的選單。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/267687.html
標籤:Android
上一篇:Java運行例外:Cannot convert result to String
下一篇:提交的應用一直不能審核通過
