我正在使用我正在使用的一个Android应用程序CoordinatorLayout,AppBarLayout并CollapsingToolbarLayout使用高级折叠栏功能.
我正在使用recyclerview来显示片段中的项目数.当我向上滚动recyclelerview时,它会平滑地折叠AppBarLayout,但当我向下滚动并到达第一项时,recyclerview它会自动停止滚动而不会扩展`AppBarLayout'.
然后我再次向下滚动以使其AppBarLayout可见.所以我的要求是当我到达recyclerview的顶部时向下滚动它必须扩展`AppBarLayout'.
我们应该怎么做.任何的想法 ?请查看相同https://www.dropbox.com/s/va5jk27ikytk5ax/app_collapsebar_issue.mp4?dl=0的视频
这是我的布局: -
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.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"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.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:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="@drawable/offer_image"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- <com.flaviofaria.kenburnsview.KenBurnsView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="220dp"
android:src="@drawable/offer_image" />-->
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<com.flaviofaria.kenburnsview.KenBurnsView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="220dp"
android:src="@drawable/offer_image" />
<FrameLayout
android:id="@+id/collapse_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B3c85a00">
</FrameLayout> …Run Code Online (Sandbox Code Playgroud) android android-recyclerview android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout
我试图在设置页面上实现与Telegram相似的行为,也就是说,有一个CircleImage,当向上滚动到Topbar标题的左边时,当向下滚动到达扩展的AppBarLayout的中间时.
我的工作基于这个例子:
https://github.com/saulmm/CoordinatorBehaviorExample
但在这种情况下,原始编码器会重新创建两次Topbar.我不想这样做,顶部栏的默认行为是我需要的,我也想利用汉堡包菜单和开箱即用的选项菜单.
这是我的视图层次结构:
DrawerLayout
|
|---CoordinatorLayout
|--AppBarLayout
| |-CollapsingToolbarLayout
| |-ImageView (backdrop image)
| |-Toolbar
|--NestedScrollView
|--ImageView (circleimage avatar)
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我不能使工具栏布局成为我的CircleImage的兄弟,因此我无法将它们绑定在layoutDependsOn方法上.我尝试绑定到AppBarLayout基于github repo上的代码,但说实话,我无法理解原始代码中发生的事情.
我正在开发一个应用程序,我正在使用带有CollapsingToolbarLayout和NestedScrollView的AppBarLayout.我已经成功实现了这个并且工作正常.
现在我想要做的是,在Nestedscrollview上进行快速刷卡时,它应该完全滚动到顶部.同样,在向屏幕底部投掷(快速向下滑动)时,它必须顺畅地滚动到底部.但是现在,它只会卡在两者之间,这使它看起来很难看.我已经尝试了许多可用的解决方案,但没有任何方法可以帮助我 我目前的设置如下.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:zhy="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="RtlHardcoded">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="246dp"
android:scaleType="fitXY"
android:tint="#11000000"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.9" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:padding="10dp">
<FrameLayout
android:id="@+id/back_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="10dp"
android:paddingTop="5dp">
<ImageView
android:id="@+id/back_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" />
</FrameLayout>
<FrameLayout
android:id="@+id/frameLayoutheart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="5dp"
android:paddingTop="5dp">
<ImageView
android:id="@+id/favbtnicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/heart_profile" />
</FrameLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/main.framelayout.title"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom|center_horizontal"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.3">
<LinearLayout …Run Code Online (Sandbox Code Playgroud) android android-collapsingtoolbarlayout android-appbarlayout android-nestedscrollview
我遇到了一些问题。我想制作一个图像、一个文本和两个图标,AppBar但我不能让它按我想要的方式工作。

我试图在图像和文本之后连续制作一些字体。图像和文本成功显示在 my 中AppBar,但其余 2 种字体(手推车和通知)显示一些错误。
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.amber,
appBar: new AppBar
(
title: new Row
(
mainAxisAlignment: MainAxisAlignment.start,
children:
[
Image.asset('images/logoapp.png',fit: BoxFit.contain,height: 32,),
Container(padding: const EdgeInsets.all(8.0), child: Text('Solid Shop'))
],
)
),
Run Code Online (Sandbox Code Playgroud)
....
我正在编写一个与ContentProvider一起使用的简单应用程序,我有一个db,一个ContentProvider,一个主要活动,一个使用ContentResolver将命令转发到ContentProvider的类.在gui上我只想显示存储在db中的所有项目.我从头开始创建这个项目,在创建Activity时,主要布局有一个CoordinatorLayout,带有AppBarLayout,没关系,我创建了一个ListView,除了appBarLayout重叠ListView,在listview的第一项下面,一切正常被AppBarLayout隐藏.

我尝试使用android:layout_below我的ListView,但它不起作用,如果我使用android:layout_marginTop然后我的ListView是在AppBarLayout下,但我没有找到这个解决方案很好.
在AppBarLayout下有没有干净简单的方法来获取ListView?
在我的activity_main布局下面:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.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:background="@color/holo_light_background"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/AppTheme.AppBarOverlay"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bar"/>
<android.support.design.widget.FloatingActionButton ...>
<android.support.design.widget.FloatingActionButton ...>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) 我正在使用CoordinatorLayout这个效果:
这是布局代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="@+id/coordinatorRootLayout"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/android_appbar_layout"
android:layout_width="match_parent"
android:layout_height="220dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayoutAndroidExample"
android:layout_width="match_parent"
android:background="#fff"
app:collapsedTitleGravity="left"
app:expandedTitleTextAppearance="@color/card_outline"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:expandedTitleGravity="center_horizontal"
app:contentScrim="?attr/colorPrimary"
app:statusBarScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="32dp"
app:expandedTitleMarginEnd="48dp">
<ImageView
android:id="@+id/parallax_header_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/orange_triangle"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.8"/>
<ImageView
app:expandedTitleGravity="center_horizontal"
android:id="@+id/someImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/circle"
android:layout_gravity="center_horizontal"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="-1"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="none"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/linear_layout_android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:background="@color/off_white"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical">
<GridView
android:id="@+id/gridview_parallax_header" …Run Code Online (Sandbox Code Playgroud) android android-layout android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout
使用Android Studio将项目迁移到AndroidX(并手动修复了很多导入错误)后,我没有遇到编译错误,但是当应用启动时,我崩溃了:
Error inflating class android.support.design.widget.AppBarLayout。
布局文件中有问题的行是:
<android.support.design.widget.AppBarLayout
我的依赖项build.gradle是:
dependencies {
def lifecycle_version = '2.1.0-alpha02'
// used below--will be different for androidx (migrated 2019-02-04)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
// Relay class
implementation 'com.jakewharton.rx2:replaying-share:2.1.0'
// ReplayingShare
implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
// RxBinding
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" // see def above
// includes ViewModel and LiveData …Run Code Online (Sandbox Code Playgroud) 我想制作像谷歌游戏商店一样的折叠工具栏布局.像这样:https: //sendvid.com/ugjspx8r
这是我的布局:http: //sendvid.com/s4mx3xem
我怎么能用新的android支持库做到这一点?
这是我的布局xml文件:
<android.support.design.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/seffafCollapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="240dp"
app:expandedTitleMarginEnd="164dp"
app:expandedTitleMarginStart="148dp"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
android:src="@drawable/haber_icerik_resim"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/haber_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolbarColoredBackArrow"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/newsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:clickable="true"
android:background="@color/mainBackground"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) android-layout android-toolbar android-collapsingtoolbarlayout android-appbarlayout
随着谷歌最近发布的设计支持库,已经引入了几个很酷的新视图.使用一些新组件(例如CoordinatorLayout)可能(!)使您能够实现滚动行为.
我尝试了一些内置的滚动行为,但没有什么对我有用,
我的布局中有一个底栏(LinearLayout)代替FloatingActionButton
这就是我想要的.
是否有任何内置机制来实现这一目标?或者我们需要编写java代码?
这是我的代码:
main_activty.xml
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include layout="@layout/toolbar_srp" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<!-- All Scrollable Views -->
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<!-- Bottom bar-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#a0000000"
android:orientation="horizontal"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="AC"
android:textColor="@color/white" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Sleeper"
android:textColor="@color/white" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33" …Run Code Online (Sandbox Code Playgroud) 进度和活动的Material Design规范在几个区域中专门显示了一个水平进度指示器,只有几个像素(下降)厚度,这些天我们称之为ActionBar(可能是工具栏).
但是,我认为没有任何方法可以实际实现Material Design的那部分.设计与现实之间似乎存在脱节.为了使事情变得更复杂,所有经典方法(例如setProgressBarIndeterminateVisibility())都被弃用或消失(即无操作).此外,在工具栏下方放置一个水平ProgressBar会导致一个非常高的ProgressBar,而且我能找到的所有备用AppCompat ProgressBar样式也太高了.试图将高度强制为'2dip'会导致收缩ProgressBar内容的宽度缩小.
那么,在Toolbar或AppBarLayout 底部放置符合Material Design标准的水平ProgressBar的正确内置AppCompat兼容方法是什么?
我更喜欢它位于AppBarLayout的底部,因为我在工具栏之后但在我的应用程序中的AppBarLayout结束之前添加了更多内容.目前,我已经降级到工具栏中的循环不确定ProgressBar,但它很大而且有点难看.
android material-design android-toolbar android-appbarlayout