我四处搜寻,找不到合适的方法.我想对我的观点产生以下阴影效果:


说实话,我不知道第二个是否通过应用阴影效果来完成.有任何想法吗?
有没有办法View在前棒棒糖设备中添加高程而不将它们包裹在CardView?
谷歌已经表明,海拔效果显示在棒棒糖一些不错的方式在这里.
android:elevation="2dp"
Run Code Online (Sandbox Code Playgroud)
按钮,
android:stateListAnimator="@anim/button_state_list_animator"
Run Code Online (Sandbox Code Playgroud)
如何在没有第三方库的情况下模仿前Lollipop版本的高程效果?
我将我的Android应用程序更新为新的材质设计,但我还想在工具栏中添加一些阴影或高程.通过图像/ 9补丁似乎有一些(hacky)方法,但我想知道它是否可以通过支持库完成.(就像CardView可以有高程)
根据这一答案的另一个问题,这是通过包装可能Toolbar在AppBarLayout,但这并不为我工作.
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout 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="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
我也尝试过通过XML和代码设置高程,但这也不起作用.
任何帮助,将不胜感激!提前致谢.
更新:
由于我在其他布局中包含了我的工具栏布局,因此下面是我的主要布局之一:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/Toolbar" />
<fragment
class="OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment"
android:id="@+id/PlanningFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我在片段之间使用动画:
从左侧滑入:
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="2000"
android:valueTo="0"
android:valueType="floatType"
android:fillAfter="true"/>
</set>
Run Code Online (Sandbox Code Playgroud)
从右侧滑入:
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-400"
android:valueType="floatType"/>
</set>
Run Code Online (Sandbox Code Playgroud)
该动画将前一个片段向左移动,而新片段从右移。我将其与片段事务一起使用。
transaction.setCustomAnimations(R.animator.slide_in_from_left,R.animator.slide_in_from_right);
Run Code Online (Sandbox Code Playgroud)
当新片段出现时,我遇到了麻烦,他将其滑到旧片段的下面,为解决此问题,我在新片段上加了一个标高,但我想在21以下使用API解决方案。是否有可能将新片段强制在较旧的片段