所以现在Android 5.0发布了,我想知道如何实现动画操作栏图标.
这个库在这里实现它很好但是因为appcompat v7库有它如何实现它?
该库在themes.xml中引用它
<item name="drawerArrowStyle">@style/Widget.AppCompat.DrawerArrowToggle</item>
Run Code Online (Sandbox Code Playgroud)
在这种风格下
<style name="Base.V7.Theme.AppCompat" parent="Platform.AppCompat">
Run Code Online (Sandbox Code Playgroud)
UPDATE
我使用v7 DrawerToggle实现了这个功能.但是我无法设计它.请帮忙
我在v7 styles_base.xml中找到了它的样式
<style name="Base.Widget.AppCompat.DrawerArrowToggle" parent="">
<item name="color">?android:attr/textColorSecondary</item>
<item name="thickness">2dp</item>
<item name="barSize">18dp</item>
<item name="gapBetweenBars">3dp</item>
<item name="topBottomBarArrowSize">11.31dp</item>
<item name="middleBarArrowSize">16dp</item>
<item name="drawableSize">24dp</item>
<item name="spinBars">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我把它添加到我的样式中并且没有用.也添加到我的attr.xml
<declare-styleable name="DrawerArrowToggle">
<!-- The drawing color for the bars -->
<attr name="color" format="color"/>
<!-- Whether bars should rotate or not during transition -->
<attr name="spinBars" format="boolean"/>
<!-- The total size of the drawable -->
<attr name="drawableSize" format="dimension"/>
<!-- The max gap …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-actionbar drawertoggle android-5.0-lollipop
我有一个AppCompatActivity控制替换许多片段.这是我的布局.
activity_main.xml中
<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/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<include layout="@layout/activity_main_frame"/>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@color/white"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
activity_main_frame.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: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_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<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"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="256dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<include layout="@layout/activity_main_items"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="bottom"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
</FrameLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/appbar" …Run Code Online (Sandbox Code Playgroud) android android-support-library android-toolbar coordinator-layout
所以现在Android 5.0发布了,我想知道如何设置动画操作栏图标的样式.
该库在这里实现和风格也对我很好,但由于程序兼容性V7库有它怎么能称呼?
我使用v7 DrawerToggle实现了这个功能.但是我无法设计它.请帮忙
我在v7 styles_base.xml中找到了它的样式
<style name="Base.Widget.AppCompat.DrawerArrowToggle" parent="">
<item name="color">?android:attr/textColorSecondary</item>
<item name="thickness">2dp</item>
<item name="barSize">18dp</item>
<item name="gapBetweenBars">3dp</item>
<item name="topBottomBarArrowSize">11.31dp</item>
<item name="middleBarArrowSize">16dp</item>
<item name="drawableSize">24dp</item>
<item name="spinBars">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我把它添加到我的样式中并且没有用.也添加到我的attr.xml
<declare-styleable name="DrawerArrowToggle">
<!-- The drawing color for the bars -->
<attr name="color" format="color"/>
<!-- Whether bars should rotate or not during transition -->
<attr name="spinBars" format="boolean"/>
<!-- The total size of the drawable -->
<attr name="drawableSize" format="dimension"/>
<!-- The max gap between the bars when they are parallel to each …Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的问题,我无法弄清楚.直到最近我才成为问题,但我似乎无法回复以防止它.另一个奇怪的事情是它适用于某些设备而其他设备则不适用.
问题是动画.特别是小吃店.小吃店应该上下动画,但事实并非如此.它只是显示然后隐藏.查看下面的视频以查看问题.
这是用于为小吃店设置动画的Android代码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
ViewCompat.setTranslationY(mView, mView.getHeight());
ViewCompat.animate(mView)
.translationY(0f)
.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
.setDuration(ANIMATION_DURATION)
.setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationStart(View view) {
mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION,
ANIMATION_FADE_DURATION);
}
@Override
public void onAnimationEnd(View view) {
onViewShown();
}
}).start();
}
Run Code Online (Sandbox Code Playgroud)
它使用ViewCompat作为v4库.我有其他动画在另一个活动工作正常.此外,问题不在于其中的所有活动.这让我以某种方式思考它的系统.但它们都使用不同的内部主题,但都扩展了Theme.AppCompat.NoActionBar.
这是我的主要布局
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="4dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextAppearance="@style/ToolbarTitle"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="@style/TabText"
app:tabMinWidth="@dimen/tab_minwidth"
app:tabMode="fixed"
app:tabGravity="fill"
app:layout_scrollFlags="enterAlways"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<fr.castorflex.android.circularprogressbar.CircularProgressBar
android:id="@+id/base_progressSpinner"
android:layout_gravity="center" …Run Code Online (Sandbox Code Playgroud) 我有一个CollapsingToolbarLayout设置,我在那里放置一个壁纸.我希望能够阻止它一直崩溃.
我已经尝试了minheight和许多其他的东西,但无法搞清楚.
如何让它停止折叠到第二个屏幕截图?
查看加载活动的时间
期望的停止点
目前的停止点
android android-design-library android-collapsingtoolbarlayout
我试图动画一个固定到我的AppBarLayout的android.support.design.widget.FloatingActionButton.我可以在布局xml中设置好,它显示正常.但是,我正在对此布局执行共享元素转换,并且在设置视图之前FAB正在显示.我尝试将可见性设置为GONE和INVISIBLE但是如果layout_anchor在布局xml中设置,它们似乎会被忽略.有没有办法解决?
我希望活动加载共享元素转换然后淡入我的FAB.我只是无法隐藏FAB的负载.我可以在不使用layout_anchor的情况下完成它,但如果可能的话,我更愿意保留它.
android android-support-library android-design-library android-coordinatorlayout android-support-design
我已经尝试了一切来使这个工作,但无法搞清楚.
我试图在我的应用程序中使用警报对话框.它适用于KitKat,但不适用于Lollipop.
我甚至尝试在GitHub上使用许多材料对话框,然后他们再次在Kitkat上工作,但在Lollipop上却没有.
我正在使用库存nexus工厂映像测试我的Nexus 5.
KITKAT与GITHUB材料对话
KITKAT与股票警报对话
LOLLIPOP与GITHUB材料对话
LOLLIPOP与股票警报对话
这也就是github上安装在同一设备上的库,它不能正常工作.所以关于我的应用程序的东西导致了这一点.会是什么呢
在我使用proguard构建版本后,将我的AppCompat库更新为25后,我的所有FloatingActionButton背景都是透明的.当我构建一个没有proguard的调试版本时,它就像应该的那样着色.
布局
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_upload"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/content_frame"
app:layout_anchorGravity="bottom|right|end"
app:borderWidth="0dp"
android:src="@drawable/app_fab_upload"
android:layout_margin="@dimen/big_padding"
android:clickable="true"
app:backgroundTint="@color/fab_social"/>
Run Code Online (Sandbox Code Playgroud)
摇篮
compileSdkVersion = 25
buildToolsVersion = '25.0.0'
supportLibVersion = '25.0.0'
supportLibAppCompat = "com.android.support:appcompat-v7:$supportLibVersion"
supportLibCardView = "com.android.support:cardview-v7:$supportLibVersion"
supportLibRecyclerView = "com.android.support:recyclerview-v7:$supportLibVersion"
supportLibDesign = "com.android.support:design:$supportLibVersion"
supportLibPalette = "com.android.support:palette-v7:$supportLibVersion"
supportLibPercent = "com.android.support:percent:$supportLibVersion"
Run Code Online (Sandbox Code Playgroud)
我的proguard配置中没有任何对AppCompat的引用.
UPDATE
我只是尝试了另一个项目,它有同样的问题.这个问题似乎源于将Android Studio更新为2.3 Canary版本.
在recyclerview中单击某个项目时,我会调用它
appbar.removeView(tabs)
该视频显示了会发生什么
它似乎完全删除TabLayout没有动画,然后将其添加回来,然后使用动画删除它.我放慢了转变速度,以显示它的作用.
当像这样添加它们时也会发生这种情况
if (tabs.parent != null) {
(tabs.parent as ViewGroup).removeView(tabs)
}
appbar.addView(tabs)
appbar.setExpanded(true, true)
Run Code Online (Sandbox Code Playgroud)
这是我的布局
<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/coordinator_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
app:elevation="0dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MyToolbar"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="@style/TabText"
android:layout_marginRight="@dimen/small_spacing"
android:layout_marginLeft="@dimen/small_spacing"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorHeight="2dp"
app:layout_scrollFlags="enterAlways"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<***.***.CustomViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)