- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 ObjectAnimator
向上滑动背景图像以显示下面的 listView
。 listView
的权重
为0.7f
,因此它在所有屏幕尺寸上的比例都相同。
使用 ObjectAnimator
是否可以将我的背景图像以相同的 0.7
比例向上滑动,在所有屏幕上都一样?
背景图片和listView
:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3" >
</LinearLayout>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:background="#303030"
android:divider="#555555"
android:dividerHeight="1dp" >
</ListView>
</LinearLayout>
动画代码:
FrameLayout mainView = (FrameLayout)findViewById(R.id.mainView);
ObjectAnimator mover = ObjectAnimator.ofFloat(mainView, "translationY", !historyShown ? -500 : 0);
mover.setDuration(300);
mover.start();
最佳答案
实际上想出了一个更快更简单的方法。由于我的 listView
使用 0.7f
的 weight
设置,它始终与所有屏幕尺寸成比例。所以,我只需要获取 listView
的高度并在我的 ObjectAnimator
中使用它:
// Figure out where listView is
int listViewHeight = list.getHeight();
FrameLayout mainView = (FrameLayout)findViewById(R.id.mainView);
ObjectAnimator mover = ObjectAnimator.ofFloat(mainView, "translationY", !historyShown ? -listViewHeight : 0);
mover.setDuration(300);
mover.start();
完美运行!
关于Android ObjectAnimator 动画 translationY 在所有屏幕尺寸上的比例相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18950808/
我有一组 View 能够在屏幕上向下移动并随后反向移动,但现在当我尝试移动 CardView 时,它会向下移动但不会向上移动。 当用户单击按钮时,它会提示 View 集合下拉/消失,当用户再次单击该按
这是我的对象动画师 xml //Animating the NormalLayout final ObjectAnimator anim4 = (ObjectAnimator) //Ob
我有一个 View (sendSidePanel),我在呈现 View 时将其隐藏: public void setListnerToRootView(){ final View activit
我正在使用 kotlin 解构声明。我之前将它与 SpringAnimation 一起使用,并且效果很好。现在我想将它与 ObjectAnimator 一起使用,但出现此错误: Destructuri
我正在尝试为进度条设置动画,以便线性填充需要 1 分钟。 这是我的代码: animator = ObjectAnimator.ofInt(progress_bar, "progress", 0, 10
我尝试在谷歌和各种堆栈问题中四处寻找,但似乎找不到与我正在做的事情相似的东西。 基本上,我只想在动画的某个偏移量处开始给定的 ObjectAnimator 动画(例如,通过动画 30%,或通过动画 7
起初,我以为我的动画根本不起作用,因为新的 Fragment ViewGroup 只会在一帧中出现在屏幕上。然后我放慢了动画速度,所以它需要 3 秒(3000 毫秒)并发现它只是以如此大的 block
我有一个包含 HorizontalScrollView 的 Activity 。 HorizontalScrollView 中有三个 fragment 。单击按钮时, ScrollView 将
我今天设计了两个可绘制的经典arrow 和hamburger 图标来重新创建和理解android 中的objectAnimator。当没有播放动画但更改了可绘制对象时会出现此问题。 我已经创建了 ic
我使用 ObjectAnimator API (android.animation.ObjectAnimator) 在按钮被点击后设置动画(v 是按钮): ObjectAnimator animato
我想要一个相对布局来放大并且 View 的底部应该是固定的。 我有一个相对布局 - private RelativeLayout rlOutdoorSection; 初始化它- rlOutdoorSe
我正在尝试查找 ObjectAnimator 可以设置动画的属性列表以及它如何设置动画。 例如,我想知道 translationY 属性是如何设置动画的。该值是要坐标还是距离? 最佳答案 Object
我正在尝试使用 Animator 集顺序播放一组动画。除了 alpha 动画 (set1) 外,一切正常。它从 0.25f 变为 1,但在整个动画中并没有消失,并且在 set1 动画结束时,它从 0.
我需要将按钮从一个位置移动到另一个位置。 View 位置移动工作正常,但只有旧区域是可点击的。 这是我的代码: Button animatorButton = (Button)findViewByI
我尝试制作ImageView 的扩展布局动画和平移 动画,但我同时启动它们时它们看起来有点滞后。我在真实设备 Moto X(2013) 上对其进行了测试。不确定更强大的设备,因为默认情况下我所有的模拟
我想使用 ObjectAnimator 在 Y 轴上移动一个 textView。这段代码有效,但由于屏幕尺寸的原因,它并不适合所有设备。 ObjectAnimator mover = Objec
我使用 Animator XML 为 ImageView 设置动画。 ImageView 应该增长(从 0f 到 1f,Y 比 X 快)并从 90 旋转 90° 到 0。我将此 XML 文件用于动画:
我正在使用 ObjectAnimator 滚动 HorizontalScrollView(左 -> 右 -> 左)。因此,结果应该是从一侧无限滚动到另一侧。 问题 是在我开始向右 -> 左设置动画
我正在尝试使用 ObjectAnimator 来制作向上滑动的翻译动画,因为我们知道,如果我们像这样使用普通的翻译动画,onclicklistener 将无法工作, 上面的 xml 代码工作正常,但
如果属性 x 被指定为字符串,ObjectAnimator 如何能够调用适当的方法 setX?我的意思是,使用什么技术来识别我想要为 View 的属性 rotation 设置动画并调用该 View 的
我是一名优秀的程序员,十分优秀!