我需要制作一个多行文本材质按钮。我遵循了这个问题的答案,但事实证明材质按钮的工作方式不同。
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggle_parent_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:theme="@style/Theme.MaterialComponents"
android:visibility="gone"
app:checkedButton="@id/button_parent"
app:singleSelection="true">
<com.google.android.material.button.MaterialButton
android:id="@+id/button_parent"
style="@style/Login.Button.ToggleButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Parent\n Device" />
<com.google.android.material.button.MaterialButton
android:id="@+id/button_child"
style="@style/Login.Button.ToggleButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Child \n Device" />
Run Code Online (Sandbox Code Playgroud)
我得到这个:

但我需要每个单词都在不同的行中,如下所示:

当我单击工具栏图标时,我试图使用有角度的材料打开侧面导航。一切正常,直到我尝试实际打开导航栏,我收到错误:
由 /src/app/app.module.ts 中的 AppModule 模块导入的意外指令 'MatDrawer in @angular/material/sidenav/index.d.ts'。请添加@NgModule 注释。
这是 npm 模块 (package.json):
"@angular/animations": "^9.1.11",
"@angular/cdk": "^9.2.4",
"@angular/common": "~9.1.11",
"@angular/compiler": "~9.1.11",
"@angular/core": "~9.1.11",
"@angular/forms": "~9.1.11",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.11",
"@angular/platform-browser-dynamic": "~9.1.11",
"@angular/router": "~9.1.11",
"jQuery": "^1.7.4",
"jquery": "^3.5.1",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
Run Code Online (Sandbox Code Playgroud)
这是我的 app.module:
import { MatDrawer } from '@angular/material/sidenav';
import { MatDrawerContainer } from '@angular/material/sidenav';
@NgModule({
declarations: [
AppComponent,
DressesComponent,
LoadingSpinnerComponent,
Toolbar,
ButtonToggle,
Sidenav
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
BrowserAnimationsModule,
MatTableModule,
MatSelectModule,
MatDialogModule,
MatInputModule,
MatToolbarModule,
MatIconModule, …Run Code Online (Sandbox Code Playgroud)