androiddesignsupport 相关问题

Android设计支持库带有导航抽屉视图,浮动标签,浮动操作按钮,快餐栏,标签以及动作和滚动框架,以将它们绑定在一起。

带有 RecyclerView 和折叠标题的 CoordinatorLayout

我的布局如下: (工具栏, 标题视图、文本视图、RecyclerView) 当我滚动 recyclerview 的项目时,我需要折叠标题。 这样视图“选择项目”和

回答 3 投票 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

带有文字的矩形(圆角)浮动操作按钮

我想知道是否可以创建一个像来自material.io 的图像中所示的工厂以及如何创建它。谢谢

回答 2 投票 0

RecyclerView(水平)嵌套在 BottomSheet 中防止垂直滚动

我有一个 RecyclerView,它使用水平方向的 LinearLayoutManager,使用 BottomSheet 行为嵌套在 FrameLayout 中。 当试图在 RecyclerVie 上垂直拖动时...

回答 2 投票 0

将ARGB颜色字符串转换为int ARGB int格式 在安卓系统中的颜色。

我需要从1个活动中传递ARGB颜色到其他活动中作为字符串。现在,我需要在其他活动中转换相同的颜色字符串,以转换为int传递到一个参数中... ...

回答 1 投票 0

在Snackbar上移动名片视图-协调器布局

我在屏幕底部的卡片视图中有一个自定义的文本视图,并使用点心栏在登录时显示错误消息。现在,当点心栏显示时,注册的文本视图应上移。我有...

回答 3 投票 1

需要面部锁定的支持

我正在尝试将面部锁与生物识别管理器集成在一起,但是它不起作用。另外,我需要检查设备是否支持面部锁定功能。让我知道有人整合了脸...

回答 1 投票 1

需要在Android中支持面部锁定

我正在尝试将面部锁与生物识别管理器集成在一起,但是它不起作用。另外,我需要检查设备是否支持面部锁定功能。让我知道有人整合了脸...

回答 1 投票 1

资源编辑未能将材料库更新到1.1.0

我已将材料库从com.google.android.material:material:1.0.0更新为com.google.android.material:material:1.1.0。更新后出现以下错误。唯一的解决方案...

回答 2 投票 0

要禁用TabLayout中的其中一个标签吗?

我需要我正在开发的应用程序的标签。所以我最后以tablayout结束,它包含几个选项卡。代码如下:private void setupNavTab(){int [] [] States = new int [] [] {...

回答 1 投票 5

Android设计支持库导航视图自定义

关于新的导航视图,我有几个问题。 1)滚动导航视图将滚动整个视图,但我只希望标题保留在该位置,并且导航项要滚动。 ...

回答 2 投票 3

卸下支持Android设计的导航抽屉滚动条?

我刚刚更新了支持设计库从22.2.1至23.0.1,并立即注意到了滚动条的抽屉式导航的存在。我试图使用Android:滚动条=“无”但是,这没” ...

回答 4 投票 11

更改导航抽屉中已选中菜单项的颜色

我正在使用新的Android Design支持库在我的应用程序中实现导航抽屉。我不知道如何更改所选项目的颜色!这是菜单的xml:&...

回答 6 投票 101


AppBarLayout和Toolbar有什么区别?

我想在我的应用程序中包含工具栏,但设计支持库刚刚推出AppBarLayout,所以我只需要澄清差异是什么以及何时使用其中一个。

回答 3 投票 88

支持库VectorDrawable Resources $ NotFoundException

我使用的是Design Support Library版本23.4.0。我启用了gradle标志:defaultConfig {vectorDrawables.useSupportLibrary = true}我正在使用构建工具版本23.0.2,但我仍然...

回答 13 投票 62

TabLayout(Android设计库)文本颜色

我正在使用Android设计库中的新TabLayout。我设法使用tabLayout.setTabTextColors(colorstatelist)设置textcolor状态列表如何使用styles.xml实现相同的功能?

回答 7 投票 83

在相对布局中显示不同位置和大小的图像

我可以在相对布局中查看回收视图图像,但是它显示的图像像固定的表格行。布局在设计中没有外观和感觉。我看起来像每个图像在不同的...

回答 1 投票 0

删除BottomNavigationView标签

谷歌发布新的支持库v25与BottomNavigationView有没有办法删除商品标签?

回答 9 投票 45

ViewHolder中的嵌套RecyclerView会破坏折叠工具栏布局

我有一个在CoordinatorLayout中托管的垂直RecyclerView,具有折叠工具栏布局。此RecyclerView的ViewHolder包含另一个带有GridLayoutManager的RecyclerView。 ...

回答 3 投票 8

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