【问题标题】:Show snackbar over status bar在状态栏上显示小吃栏
【发布时间】:2021-07-19 15:11:22
【问题描述】:

我想在状态栏和工具栏上显示一个快餐栏。然后,拥有这个屏幕:

它应该显示为:

这可能吗?我什么都没找到。

【问题讨论】:

    标签: android


    【解决方案1】:

    是的,我想是的。您可以将应用程序设置为全屏,这样状态栏就不会出现。 如果您正在使用 AppCompatActivity 来设计您的工具栏,您可以使用类似的东西:

    private void configureToolbar(){
        // Get the toolbar view inside the activity layout
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        // Set the Toolbar
        setSupportActionBar(toolbar);
    }
    

    在您的活动主目录中,包括工具栏:

    <include
        layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    

    为酒吧创建一个布局,你就可以开始了:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Déclaration de notre Toolbar -->
    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        
        android:id="@+id/toolbar"
        android:minHeight="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        
        android:theme="@style/ToolbarTheme"
        app:titleTextAppearance="@style/Toolbar.TitleText"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      • 2012-04-06
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      • 2019-04-13
      相关资源
      最近更新 更多