Java 在Android Studio中制作抽认卡
我是android编程的新手。我想制作一个有抽认卡的应用程序。这些抽认卡上会有单词,当我触摸它们时,它会显示单词的含义 我搜索了谷歌。但我找不到制作抽认卡的合适教程Java 在Android Studio中制作抽认卡,java,android,Java,Android,我是android编程的新手。我想制作一个有抽认卡的应用程序。这些抽认卡上会有单词,当我触摸它们时,它会显示单词的含义 我搜索了谷歌。但我找不到制作抽认卡的合适教程 谢谢 欢迎来到Android Richa 我为您找到了一些有用的链接: 基本上,您将使用动画和图像视图。 这里列出的最佳链接是“翻转动画说明” 您将设置卡的布局,然后设置活动。一旦这一切就绪,您将在XML中制作动画 我在这里找到了代码: 主要活动 public class MainActivity extends AppCo
谢谢 欢迎来到Android Richa 我为您找到了一些有用的链接: 基本上,您将使用动画和图像视图。 这里列出的最佳链接是“翻转动画说明” 您将设置卡的布局,然后设置活动。一旦这一切就绪,您将在XML中制作动画 我在这里找到了代码: 主要活动
public class MainActivity extends AppCompatActivity {
private AnimatorSet mSetRightOut;
private AnimatorSet mSetLeftIn;
private boolean mIsBackVisible = false;
private View mCardFrontLayout;
private View mCardBackLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
loadAnimations();
changeCameraDistance();
}
private void changeCameraDistance() {
int distance = 8000;
float scale = getResources().getDisplayMetrics().density * distance;
mCardFrontLayout.setCameraDistance(scale);
mCardBackLayout.setCameraDistance(scale);
}
private void loadAnimations() {
mSetRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.out_animation);
mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.in_animation);
}
private void findViews() {
mCardBackLayout = findViewById(R.id.card_back);
mCardFrontLayout = findViewById(R.id.card_front);
}
public void flipCard(View view) {
if (!mIsBackVisible) {
mSetRightOut.setTarget(mCardFrontLayout);
mSetLeftIn.setTarget(mCardBackLayout);
mSetRightOut.start();
mSetLeftIn.start();
mIsBackVisible = true;
} else {
mSetRightOut.setTarget(mCardBackLayout);
mSetLeftIn.setTarget(mCardFrontLayout);
mSetRightOut.start();
mSetLeftIn.start();
mIsBackVisible = false;
}
}
}
在这里,您正在干扰摄影机距离,以确保在屏幕上看到翻转动画。因为它可能越过“虚拟线”,根本看不见
卡正面XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
卡回XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
活动XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
在动画XML中
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
输出动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="0"
android:valueTo="180"
android:propertyName="rotationY"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
欢迎来到Android Richa 我为您找到了一些有用的链接: 基本上,您将使用动画和图像视图。 这里列出的最佳链接是“翻转动画说明” 您将设置卡的布局,然后设置活动。一旦这一切就绪,您将在XML中制作动画 我在这里找到了代码: 主要活动
public class MainActivity extends AppCompatActivity {
private AnimatorSet mSetRightOut;
private AnimatorSet mSetLeftIn;
private boolean mIsBackVisible = false;
private View mCardFrontLayout;
private View mCardBackLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
loadAnimations();
changeCameraDistance();
}
private void changeCameraDistance() {
int distance = 8000;
float scale = getResources().getDisplayMetrics().density * distance;
mCardFrontLayout.setCameraDistance(scale);
mCardBackLayout.setCameraDistance(scale);
}
private void loadAnimations() {
mSetRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.out_animation);
mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.in_animation);
}
private void findViews() {
mCardBackLayout = findViewById(R.id.card_back);
mCardFrontLayout = findViewById(R.id.card_front);
}
public void flipCard(View view) {
if (!mIsBackVisible) {
mSetRightOut.setTarget(mCardFrontLayout);
mSetLeftIn.setTarget(mCardBackLayout);
mSetRightOut.start();
mSetLeftIn.start();
mIsBackVisible = true;
} else {
mSetRightOut.setTarget(mCardBackLayout);
mSetLeftIn.setTarget(mCardFrontLayout);
mSetRightOut.start();
mSetLeftIn.start();
mIsBackVisible = false;
}
}
}
在这里,您正在干扰摄影机距离,以确保在屏幕上看到翻转动画。因为它可能越过“虚拟线”,根本看不见
卡正面XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
卡回XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
活动XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
在动画XML中
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardFront"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/front"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/cardBack"
android:padding="16dp"
android:src="@drawable/rectangle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/back"
android:textColor="@color/white"
style="@style/Base.TextAppearance.AppCompat.Display1"
android:gravity="center"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context="blog.droidsonroids.pl.blogpost.MainActivity"
android:onClick="flipCard">
<FrameLayout
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/card_back" />
</FrameLayout>
<FrameLayout
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<include layout="@layout/card_front" />
</FrameLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:repeatMode="reverse"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
输出动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:valueFrom="0"
android:valueTo="180"
android:propertyName="rotationY"
android:duration="@integer/anim_length" />
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:startOffset="@integer/anim_length_half"
android:duration="0" />
</set>
虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-更新和完全回答!非常好,我的成绩是+1@RichaTibrewal记住,如果这能解决您的问题,请投票并将此答案标记为已接受。非常感谢。虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-更新和完全回答!非常好,我的成绩是+1@RichaTibrewal记住,如果这能解决您的问题,请投票并将此答案标记为已接受。非常感谢。我已经在下面提供了完整的工作解决方案。让我知道这是否解决了你的问题!我已经在下面提供了完整的工作解决方案。让我知道这是否解决了你的问题!