android-toolbar 相关问题

工具栏是基于窗口小部件的广告,用于在布局中使用的操作栏。

无法捕获工具栏主页按钮单击事件

我已经实现了最新的appcompat库并使用工具栏作为操作栏。但问题是我无法捕获主页按钮/汉堡包图标单击事件。我已经尝试并查看了所有内容,但是

回答 13 投票 0

使用 AppCompat ActionBarActivity 更改状态栏颜色

在我的一项活动中,我使用调色板更改了工具栏颜色。但在使用 ActionBarActivity 的 5.0 设备上,状态栏颜色是我的活动主题中 colorPrimaryDark 的颜色,所以我...

回答 11 投票 0

Android Studio 工具栏中未显示搜索菜单

我制作了一个带有标题和功能弹出菜单的自定义工具栏,但我似乎无法在工具栏中显示搜索菜单。为此,搜索菜单图标甚至不会显示在工具栏中

回答 1 投票 0

在 CoordinatorLayout 中的工具栏下方添加视图

我有以下布局: 我有以下布局: <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.design.widget.CoordinatorLayout> 我将 Fragment 添加到 FrameLayout 中,替换它们。我的 Fragment 之一是一个列表,其布局如下: <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 我的问题是工具栏绘制在列表上。我尝试通过将 CoordinatorLayout 的内容包装到 LinearLayout 中来解决这个问题,这解决了透支问题,但这样应用程序栏滚动行为就不再起作用。 非常感谢任何帮助! 获取属性 app:layout_behavior="@string/appbar_scrolling_view_behavior" 从 RecyclerView 上取下并将其放在您要在 FrameLayout 下显示的 Toolbar 上。 我发现滚动视图行为所做的一件重要的事情是将组件布局在工具栏下方。因为 FrameLayout 有一个会滚动的后代 (RecyclerView),所以 CoordinatorLayout 将获取用于移动 Toolbar 的滚动事件。 另一件事要注意:布局行为将导致 FrameLayout 高度调整大小 就好像 Toolbar 已经滚动,并且随着 Toolbar 完全显示,整个视图被简单地向下推,因此视图的底部低于 CoordinatorLayout 的底部。 这对我来说是一个惊喜。我期望随着工具栏上下滚动,视图会动态调整大小。因此,如果您的视图底部有一个带有固定组件的滚动组件,则在完全滚动 Toolbar 之前,您将看不到该底部组件。 因此,当我想在 UI 底部锚定一个按钮时,我通过将按钮放在 CoordinatorLayout (android:layout_gravity="bottom") 的底部并在视图中添加等于按钮高度的底部边距来解决此问题工具栏下方。 我设法通过添加来解决这个问题: android:layout_marginTop="?android:attr/actionBarSize" 像这样到FrameLayout: <FrameLayout android:id="@+id/content" android:layout_marginTop="?android:attr/actionBarSize" android:layout_width="match_parent" android:layout_height="match_parent" /> 使用折叠顶部工具栏或使用您自己选择的 ScrollFlags 我们可以这样做:从Material Design摆脱FrameLayout <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <com.google.android.material.appbar.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" app:expandedTitleGravity="top" app:layout_scrollFlags="scroll|enterAlways"> <androidx.appcompat.widget.Toolbar android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin"> <ImageView android:id="@+id/ic_back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_arrow_back" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="back" android:textSize="16sp" android:textStyle="bold" /> </androidx.appcompat.widget.Toolbar> </com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.AppBarLayout> <androidx.recyclerview.widget.RecyclerView android:id="@+id/post_details_recycler" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="5dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> 从 Android studio 3.4 开始,您需要将此行放入包含 RecyclerView 的布局中。 app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior" 看一下。尝试给予与工具栏相同大小的边距 <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior" tools:context=".MainActivity"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true"> <com.google.android.material.appbar.MaterialToolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" /> </com.google.android.material.appbar.AppBarLayout> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/constraintLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="?attr/actionBarSize"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" app:layout_anchor="@+id/constraintLayout" app:layout_anchorGravity="center" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

回答 5 投票 0

工具栏不允许在其中使用匹配父布局

我设计了一个工具栏,但它不允许我制作匹配父级布局。它的左侧被锁定,不允许我将 TextView 放在那里,但右侧表现良好; 我看过...

回答 2 投票 0

如何在 Android 工具栏中居中按钮

我是 Android 应用程序开发新手。我正在尝试创建一个工具栏,上面有 3 个按钮,左侧中间和中间。我的左右按钮位置正确,但我的中间按钮显示...

回答 3 投票 0

fillMaxSize() 和 textAlign 在工具栏 jetpack compose 中不起作用

我有一个标题为“Shoes Marketplace”的工具栏,我希望这个标题位于中心。 我的代码: 脚手架( containerColor = Color(33, 17, 52), // 设置整体背景颜色...

回答 2 投票 0

如何在使用带有底部导航组件的片段管理器时更改片段工具栏的标签

我得到了 3 个碎片和 1 个活动。 MainActivity、CameraFragment、HomeFragment、HistoryFragment 我只想保存所有 HistoryFragment 状态,这样每当用户访问它时,它就不会再次重新创建。 什...

回答 1 投票 0

Android Xml 布局问题导致 textView 下移

我不知道为什么布局设计在模拟器上看起来是正确的。 请检查屏幕截图和代码。几乎就像有东西在其他东西之上一样,导致工具栏和

回答 1 投票 0

使用导航组件,bottomnavmenu 在 Android 工具栏中自定义后退图标

我想在使用导航组件和底部导航菜单时在工具栏中使用我自己的后退图标。 我已经尝试了所有可能的解决方案,但仍然显示默认的后退图标。 当我写作时 绑定。

回答 2 投票 0

工具栏中的导航图标着色

如何给菜单图标着色已经介绍过几次了,如下所示: Android 上的工具栏图标着色 除了这个解决方案之外,还存在导航图标的问题。 应用主题(

回答 3 投票 0

如何使工具栏背景透明

我设置了折叠工具栏,一切都按预期工作。只有一个问题,当工具栏折叠时,工具栏后面有一个白色的矩形视图,如图...

回答 1 投票 0

如何在 Jetpack Compose 中添加工具栏?

我需要在我的 Android 应用程序中添加一个工具栏,其中包含如下所示的列表。我正在使用 Jetpack Compose 创建 UI。下面是我用来绘制主视图的可组合函数。 @Compos...

回答 3 投票 0

如何在android studio Kotlin中创建像uc浏览器搜索栏工具栏一样的搜索栏?

首页是uc浏览器工具栏 当用户单击主屏幕上的搜索栏时,它会展开左端用户所需的搜索引擎和右端取消按钮以及在搜索之间的麦克风...

回答 1 投票 0

如何为每个片段应用不同的工具栏(操作栏)布局?

我正在应用单活动架构,我想通过工具栏使用顶部固定栏。 在我的项目中,工具栏的形式因片段而异,并且形式我...

回答 1 投票 0

将工具栏添加到首选项屏幕片段

我正在尝试通过工具栏使用 Android Jetpack 设置指南。指南说根标签是 ,所以我不能在 xml 中包含工具栏。我正在使用 NoAct...

回答 3 投票 0

折叠工具栏折叠时图像模糊

我的工具栏需要一些帮助。 现在我使用带有图像的折叠工具栏,当我向上滚动时该工具栏会折叠。 我知道我可以使用 contentScrim 使工具栏透明,因此可以看到

回答 1 投票 0

Material Design 3 顶部应用栏没有阴影。如何启用它?

新的“Material Design 3 top app bar”文档说他们摆脱了阴影。 我怎样才能启用它?在 Toolbar 或 AppBar 上设置高度根本不起作用。

回答 2 投票 0

如何仅在滚动对屏幕来说太大的 RecyclerView 时才使用 MotionLayout 隐藏/显示视图?

我有一个用于搜索的片段。它的布局在顶部有一个“搜索栏”,然后是我显示结果的 TextView 和 RecyclerView。我想隐藏/

回答 0 投票 0

如何更改android顶部工具栏菜单项图标大小

如何更改 android 工具栏中菜单项的大小?目前菜单的尺寸非常小,我想增加尺寸。如果有人知道,请帮助我找到解决方案。 应用程序_...

回答 4 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.