Spi*_*ail 3 android android-transitions
我正在使用4.4中引入的场景/过渡系统来简单地将图像视图从左侧移动到屏幕的中心.因此,我的第一个场景的布局要求图像在屏幕外.我尝试android:layout_marginRight但没有效果.这样做的正确方法是什么?
使用属性translationX或translationY负值.此属性设置此视图相对于其左/上位置的水平/垂直位置.您不会在预览中看到关闭屏幕的视图.运行您的应用程序,必须隐藏视图.
例:
<FrameLayout 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">
<android.support.design.widget.FloatingActionButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="16dp"
android:translationX="-72dp"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
然后在活动或片段中简单地调用该animate()函数.
FloatingActionButton button = (FloatingActionButton)findViewById(R.id.button);
button.animate().translationX(0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4891 次 |
| 最近记录: |