Я занимаюсь обучающим приложением, в котором задается набор вопросов с несколькими вариантами ответов. Я бы хотел сделать анимацию слайдов между двумя вопросами - когда пользователь правильно отвечает на один вопрос, он скользит влево, а новый - справа.
В настоящее время мой макет вопроса / ответа выглядит следующим образом (question.xml):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:id="@+id/question"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="8pt"
android:textStyle="bold"
android:layout_margin="5px"
android:layout_marginBottom="10dp"
android:clickable="true"
/>
<RadioGroup android:id="@+id/answers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5px"
>
<RadioButton android:id="@+id/answer_a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
<RadioButton android:id="@+id/answer_b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
<RadioButton android:id="@+id/answer_c"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
</RadioGroup>
</LinearLayout>
</ScrollView>
После ответа на вопрос и оценки ответа я просто изменил текст вопроса и три ответа. Довольно просто.
Теперь я попытался использовать 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>
Но таким образом я не могу получить доступ к просмотрам в текущем и следующем вопросе отдельно через findViewById
.
Нужно ли для этого иметь два одинаковых макета вопросов только с разными идентификаторами? это кажется излишним для меня. Или есть другой способ получить доступ к только к вопросу и ответам во втором представлении?
Или есть более простой способ сделать это?
Спасибо!