有AppBarLayout没有办法让没有阴影并保持其高度?
<android.support.design.widget.AppBarLayout
app:elevation="0dp">
Run Code Online (Sandbox Code Playgroud) android shadow android-toolbar android-elevation android-appbarlayout
我正在尝试实现一种滚动技术,具有重叠内容的灵活空间,在Material Design中有所描述.
灵活的空间,内容重叠
内容可以与应用栏重叠.
行为:
应用栏的起始位置应位于内容后面.向上滚动时,应用栏应滚动得比内容更快,直到内容不再重叠.一旦锚定到位,应用栏就会抬起以允许内容在下方滚动.
但问题是,我的AppBar中的标题在展开时向下滚动并隐藏在重叠内容之下.
这是我的代码:
活动的main.xml中
<android.support.design.widget.CoordinatorLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
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:layout_width="match_parent"
android:layout_height="match_parent"
...
Run Code Online (Sandbox Code Playgroud)
我还在MainActivity的onCreate函数中添加了这些
setSupportActionBar(toolbar);
collapsingToolbarLayout.setTitle("App Name");
Run Code Online (Sandbox Code Playgroud)
我希望工具栏(包含瓷砖和其他内容,稍后我将添加)保持在顶部,无论appbar是否被展开或折叠.
我已经阅读了文档,经历了很多帖子和教程,观看了很多视频,但却找不到工作解决方案或任何相关的解决方案.
如果有人对如何解决这个问题有所了解,请提出建议.谢谢你的帮助.
我有一个简单的活动,文本视图后跟两个编辑文本.当我开始输入时,软键盘会向上推动布局并隐藏操作栏,我将无法选择/复制/粘贴文本.
我的活动如下:
当我开始输入时,操作栏会被隐藏,就像这样 - 更重要的是,请注意,即使文本突出显示,也会丢失正常的复制粘贴栏:
我该怎么做才能确保操作栏不隐藏?
在我的活动清单中,我使用的是adjustPan.我不想使用adjustResize.
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
我的活动在这里:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/app_theme.app_bar_overlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/app_theme.popup_overlay" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_margin"
android:fillViewport="true"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@android:color/darker_gray"
android:text="My holiday story here." />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/activity_margin" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gap_normal"
android:gravity="top"
android:text="My Holiday in Europe" />
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="top"
android:text="My holiday …Run Code Online (Sandbox Code Playgroud) android android-softkeyboard android-activity android-actionbar android-appbarlayout
我MapFragment里面的视差效果AppBarLayout:
我想禁用滚动AppBarLayout,因为无法在地图上移动,因为地图上的触摸偶数总是作为滚动事件处理.我想AppBarLayout通过RecyclerView仅滚动来处理折叠,这是在屏幕的底部.
这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="@color/white"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true">
<fragment
android:id="@+id/map"
android:name="com.androidmapsextensions.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="73dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<include
android:id="@+id/search_bar"
layout="@layout/layout_searchbar" />
</android.support.v7.widget.Toolbar>
<View
android:id="@+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_below="@id/search_bar"
android:layout_gravity="bottom"
android:background="@drawable/toolbar_dropshadow"
android:visibility="gone" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RecyclerView
android:id="@+id/farm_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Run Code Online (Sandbox Code Playgroud)
感谢您的答复.
android supportmapfragment android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout
我有一个活动,它实现使用具有视差的标题图片和滚动内容的共用图案CoordinatorLayout,AppBarLayout和CollapsingToolbarLayout.我的xml布局如下所示:
<android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<TextView
android:background="@color/colorAccent"
android:gravity="center"
android:layout_height="250dp"
android:layout_width="match_parent"
android:text="ParallaxImage"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/content"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:layout_width="wrap_content"
android:text="@string/large_text"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
正如您在下面的gif动画中看到的,一切正常.您可以从内容NestedScrollView以及Toolbar视差或视差中滚动整个屏幕View.
谷歌推出了一个BottomSheetBehavior类(Android设计支持库23.2),以帮助开发人员实现Bottom表.我的带有Bottom工作表的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:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<!-- ommited …Run Code Online (Sandbox Code Playgroud) android android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout bottom-sheet
我有一个带有CoordinatorLayout,AppBarLayout和NestedScrollView的布局,在NestedScrollView中我有多个CardViews,一切正常,直到我将CardViews设置为可点击,然后如果我在CardView中开始滚动,则滚动不起作用.
这是我的布局:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_height="256dp"
android:layout_width="match_parent"
app:contentScrim="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_gravity="fill_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="0dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@color/primary" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:paddingBottom="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:includeFontPadding="false"
android:text="Title1"
style="@android:style/TextAppearance.Medium" />
<TextView …Run Code Online (Sandbox Code Playgroud) android android-design-library android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout
如何摆脱状态栏中的高程?如果我在AppbarLayout中设置应用程序:提升到0dp,状态栏中不再出现提升,也不会低于AppbarLayout.
如何获得AppbarLayout下的高程?
这是我的意思截图:毛茸茸的链接,注意状态栏中的阴影:(
谢谢!
将CoordinatorLayout与ViewPager和ViewPager结合使用时遇到问题:

布局未正确调整大小.认为解决的高度包括标签高度.所以当我滚动到底部时,我看到了这个:
主要布局代码:
<?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:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
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"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/content_main" />
</FrameLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
标签布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.MainActivity"
tools:showIn="@layout/activity_main"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<FrameLayout
android:id="@+id/regularLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
子布局代码
<RelativeLayout …Run Code Online (Sandbox Code Playgroud) android android-layout android-viewpager android-coordinatorlayout android-appbarlayout
我有一个使用新的CoordinatorLayout/AppBarLayout/CollapsingToolbarLayout范例的片段,我希望能够检测到折叠工具栏何时完全展开,以便我可以对它所在的整个片段执行操作,例如弹出片段离开堆栈并转到新的,解散片段.我有解雇代码工作,我只需要知道何时何时不使用它.
我已经用AppBarLayout.OnOffsetChangedListener进行了一些实验,但没有太多运气.有没有办法用它来确定什么时候完全扩展,或者有人知道更优选的方法?
提前致谢!
编辑:我也看到AppBarLayout.setExpanded(...)有几个实现,但不是AppBarLayout.getExpanded()或类似的东西,所以我也被困在那里.
android android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout
我正在开发一个聊天屏幕.它包括用于用户个人资料图像的CollapsingToolbarLayout,用于消息列表的RecyclerView和用于发送消息的编辑框.我无法弄清楚是否可以将编辑框固定到底部屏幕并防止它与屏幕的其余部分滚动?
如果我在一个垂直的LinearLayout中包装CoordinatorLayout并将EditText放在CoordinatorLayout之外,我几乎达到了我想要的效果.但是在这种情况下,键盘行为与RecyclerView分离 - 当您打开键盘时,它不会向上/向下滚动.
如果我尝试将EditText放在CoordinatorLayout中,它会滚出屏幕,我不知道是否需要为它设置任何特殊的行为
我的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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/keyboard_listener"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<RecyclerView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:clipToPadding="false"
android:focusableInTouchMode="true"
android:paddingBottom="20dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:transcriptMode="normal"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
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/screen_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false"
>
<FrameLayout
android:id="@+id/toolbar_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Toolbar
android:id="@+id/screen_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<EditText
android:id="@+id/messageEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/send_hint"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="2000"
android:maxLines="4"
android:padding="10dp"
android:textSize="14sp"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) android android-layout android-coordinatorlayout android-appbarlayout