Android 在相同类型的视图之间制作动画的正确方法?
我正在做一个练习多项选择题的培训应用程序。我想在两个问题之间做一个幻灯片动画-当用户正确回答一个问题时,它会向左滑动,而新的问题会从右滑入 目前,我的问答布局如下(question.xml):Android 在相同类型的视图之间制作动画的正确方法?,android,animation,viewflipper,Android,Animation,Viewflipper,我正在做一个练习多项选择题的培训应用程序。我想在两个问题之间做一个幻灯片动画-当用户正确回答一个问题时,它会向左滑动,而新的问题会从右滑入 目前,我的问答布局如下(question.xml): 在回答问题并评估答案后,我只是更改了问题的文本和三个答案。很简单 现在,我尝试使用ViewFlipper制作动画: <ViewFlipper android:id="@+id/flipper" android:layout_width="fill_parent" android:
在回答问题并评估答案后,我只是更改了问题的文本和三个答案。很简单
现在,我尝试使用ViewFlipper制作动画:
<ViewFlipper android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="@+id/current_view" layout="@layout/question" />
<include android:id="@+id/next_view" layout="@layout/question" />
</ViewFlipper>
但这样我就无法通过findviewbyd
分别访问当前问题和下一个问题中的视图
我需要有两个相同的问题布局,只是不同的ID来做这件事?这对我来说似乎是多余的。或者是否有其他方法仅访问第二个视图中的问题和答案?还是有更简单的方法来实现这一点
谢谢 好的,最后我做了这个-每次我准备一个新问题时,我都会膨胀
questions.xml
布局,将它添加到翻页器并翻转它。
由于我不希望翻页变得巨大,如果有多个,我会删除以前的旧翻页(基本上总是第一次除外)
这是正确的方法吗
<ViewFlipper android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="@+id/current_view" layout="@layout/question" />
<include android:id="@+id/next_view" layout="@layout/question" />
</ViewFlipper>
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.question, null);
txtPracticeQuestion = (TextView) layout.findViewById(R.id.question);
rgrpPracticeAnswers = (RadioGroup) layout.findViewById(R.id.answers);
rbtnPracticeAnswerA = (RadioButton) layout.findViewById(R.id.answer_a);
rbtnPracticeAnswerB = (RadioButton) layout.findViewById(R.id.answer_b);
rbtnPracticeAnswerC = (RadioButton) layout.findViewById(R.id.answer_c);
rbtnPracticeAnswerA.setOnClickListener(this);
rbtnPracticeAnswerB.setOnClickListener(this);
rbtnPracticeAnswerC.setOnClickListener(this);
txtPracticeQuestion.setText(currentQuestion.get("question").toString());
rbtnPracticeAnswerA.setText(currentQuestion.get("answer_a").toString());
rbtnPracticeAnswerB.setText(currentQuestion.get("answer_b").toString());
rbtnPracticeAnswerC.setText(currentQuestion.get("answer_c").toString());
if (flipper.getChildCount() > 1)
flipper.removeViewAt(0);
flipper.addView(layout);