相关疑难解决方法(0)

如何在RecyclerView项目出现时为其设置动画

如何出现时,如何为RecyclerView项目设置动画?

默认项目animator仅在设置回收器数据后添加或删除数据时动画.我是新开发的应用程序,并没有任何线索从哪里开始.

任何想法如何实现这一目标?

android android-layout android-recyclerview

221
推荐指数
8
解决办法
22万
查看次数

如何在BackStack上反转片段动画?

我认为当使用以下代码使用片段时按下后退按钮时,系统会反转backstack上的动画:

FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out);
ft.replace(R.id.viewContainer, new class(), "layout").addToBackStack(null).commit();
Run Code Online (Sandbox Code Playgroud)

android android-animation android-fragments back-stack

112
推荐指数
3
解决办法
4万
查看次数

Android FragmentTransaction自定义动画(未知动画名称:翻译)

我正在尝试使用自定义动画来处理我的片段.

我已经按照在线教程,但我得到了以下错误:

java.lang.RuntimeException:未知的动画师名称:translate

动画的XML如下:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
    android:fromXDelta="100%"
    android:toXDelta="0"
    android:duration="300" />
</set>
Run Code Online (Sandbox Code Playgroud)

Java文件如下所示:

public void goCategory(View v) {        
    FragmentTransaction ft = fm.beginTransaction();     
    ft.setCustomAnimations(R.animator.anim_in_left, R.animator.anim_out_left);              
    ft.show(fragment);
    ft.commit();
}
Run Code Online (Sandbox Code Playgroud)

我无法理解其他线程中的解决方案.如果有人能为我愚蠢,我真的很感激.

android android-animation android-fragments

67
推荐指数
2
解决办法
5万
查看次数

在更改图像资源时在ImageView上创建动画

ImageView我的布局中只有一个,当检测到gasture事件时,我正在更改其资源.我只想在更改ImageView的资源时显示动画.我可以使用ViewFlipperoneImageView的?

android

20
推荐指数
3
解决办法
4万
查看次数

活动动画从底部滑动

我用的是什么:

activity_stay.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="@android:integer/config_longAnimTime"
        android:fromYDelta="0%p"
        android:toYDelta="0%p" />

</set>
Run Code Online (Sandbox Code Playgroud)

activity_slide_to_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <translate
        android:duration="@android:integer/config_longAnimTime"
        android:fromYDelta="0"
        android:toYDelta="100%p" />

</set>
Run Code Online (Sandbox Code Playgroud)

activity_slide_from_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <translate
        android:duration="@android:integer/config_longAnimTime"
        android:fromYDelta="100%p"
        android:toYDelta="0" />

</set>
Run Code Online (Sandbox Code Playgroud)

启动NewActivity:

startActivity(NewActivity.getIntent(this))
overridePendingTransition(R.anim.activity_slide_from_bottom, R.anim.activity_stay)
Run Code Online (Sandbox Code Playgroud)

NewActivity完成():

finish()
overridePendingTransition(R.anim.activity_stay, R.anim.activity_slide_to_bottom)
Run Code Online (Sandbox Code Playgroud)

当NewActivity启动时,OldActivity消失 - 我看到空白的白色屏幕,NewActivity在其上方滑动到顶部.但是我需要的是我的NewActivity在启动时滑到OldActivity内容之上.我怎样才能做到这一点?

UPD:当我因为某些原因完成NewActivity时,所有动画都会完美执行:NewActivity滑到底部,OldActivity内容出现在NewActivity内容之下.

android android-animation android-xml android-activity android-transitions

15
推荐指数
3
解决办法
6844
查看次数

Android中从一个活动移动到另一个活动期间的动画转换

当从android中的一个活动另一个活动改变时,我需要动画转换.像滑动标签一样过渡.

android

5
推荐指数
1
解决办法
2805
查看次数

如何将一个视图滑出另一个视图

我在左上角有一个带有导航菜单的片段。在活动开始时,我想逐渐从菜单图标中滑出一个视图(我们称之为black_view)。

以下是我希望动画与下图一致的粗略细分:

  1. Activity 作为第一张图像开始,black_view不可见。
  2. black_view逐渐从菜单图标后面滑出长度,直到到达第二个图像的点。

第一个片段 >>> 在此处输入图片说明


我试过的:

我尝试通过使用TranslateAnimation来实现这一点。但是,black_view的整个长度出现在动画开始时,这不是我想要的。我还看到一对夫妇的滑动动画代码片段像这个这个,但他们都遵循TranlateAnimation模型(与整个长度black_view显示瞬间)。

我怎样才能做到这一点?

PS:如果有任何我没有添加的重要细节,请告诉我。

android android-animation

4
推荐指数
1
解决办法
907
查看次数

从左到右,从右到左滑动图像

我正在开发一个应用程序,我想在其中添加可以从左到右,从右到左滑动的图像,如下图所示.内部白色游戏图像应该从左到右移动,反之亦然.

在此输入图像描述

到目前为止我所做的是,我能够从左到右移动单个图像,反之亦然,但我想要设置背景图像以及上面圆形黑色背景.

这是我的代码:

imageView.setOnTouchListener(new OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
        int eid = event.getAction();
        switch (eid) {
        case MotionEvent.ACTION_MOVE:

            RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
            int x = (int) event.getRawX();
            mParams.leftMargin = x - 50;
            imageView.setLayoutParams(mParams);

            break;

        default:
            break;
        }
        return true;
    }
});
Run Code Online (Sandbox Code Playgroud)

编辑

我尝试通过设置我的布局xml来管理背景图像,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="49dp"
        android:background="@drawable/set_user_profile_back"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/hello_world"
            android:src="@drawable/next" />
    </RelativeLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

但是现在我面临图像尺寸问题,图像尺寸减小,如何解决这个问题以及如何修复图像移动的起点和终点.

在此输入图像描述

任何想法和建议都将被适用

android

2
推荐指数
1
解决办法
5210
查看次数

在webview数据上滑动动画

我正在显示我在webview中显示的数据描述以及当我点击下一步时我正在更改webview数据现在我想在动画中显示某种幻灯片,同时更改webview的数据可以有人建议我如何将动画设置为单一的webview ??

谢谢

android webview android-animation layout-animation

1
推荐指数
1
解决办法
5570
查看次数

android中使用导航组件上下滑动事务动画片段

我在我的应用程序中使用导航组件。我为片段事务设置了向上/向下滑动动画。但我没有得到想要的结果。我想要的行为是:当新片段(A)替换为前一个片段(B)时,前一个片段保持固定(没有动画)和新的片段从上到上下降,当用户按下返回按钮时,片段 B 从上向下滑动,片段 A 保持固定。我目前得到的行为:当新片段(A)替换为前一个片段(B)时,前一个片段也移动了,当用户按下后退按钮时,片段 A 也移动了。这是我使用过的四个动画文件:enter_from_up.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:interpolator="@android:anim/linear_interpolator">

<translate
        android:fromXDelta="0%" android:toXDelta="0%"
        android:fromYDelta="-100%" android:toYDelta="0%"
        android:duration="350" />
Run Code Online (Sandbox Code Playgroud)

exit_from_down.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:interpolator="@android:anim/linear_interpolator">

<translate
        android:fromXDelta="0%" android:toXDelta="0%"
        android:fromYDelta="0%" android:toYDelta="100%"
        android:duration="350" />
Run Code Online (Sandbox Code Playgroud)

enter_from_down.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:interpolator="@android:anim/linear_interpolator">

<translate
        android:fromXDelta="0%" android:toXDelta="0%"
        android:fromYDelta="100%" android:toYDelta="0%"
        android:duration="350" />
Run Code Online (Sandbox Code Playgroud)

exit_from_up.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false"
    android:interpolator="@android:anim/linear_interpolator">

    <translate
            android:fromXDelta="0%" android:toXDelta="0%"
            android:fromYDelta="0%" android:toYDelta="-100%"
            android:duration="350" />
</set>
Run Code Online (Sandbox Code Playgroud)

这是我的导航图的代码:

 <action 
android:id="@+id/action_welcomeFragment_to_signUpOneFragment" app:destination="@id/signUpOneFragment"
app:enterAnim="@anim/enter_from_down" 
app:exitAnim="@anim/exit_from_up"
app:popEnterAnim="@anim/enter_from_up" 
app:popExitAnim="@anim/exit_from_down"/>
Run Code Online (Sandbox Code Playgroud)

xml animation android android-fragments

1
推荐指数
1
解决办法
716
查看次数