Я пишу приложения для боевых искусств для нашего клуба. Есть список форм с CardView и иконками. Когда вы нажимаете кнопку видео или диаграммы, изображение перемещается и увеличивается по мере загрузки действия. Это здорово выглядит! Переход отлично работает для страницы диаграммы, однако на странице видео есть YouTubePlayerView, который «прилипает» на секунду, когда нажата кнопка «Назад» и переход меняется на обратный. Это означает, что при возврате к предыдущей странице в середине экрана появляется большой черный квадрат.
Я пытался исключить YouTubePlayerView из перехода (все еще присутствует в моем коде ниже), но это не такработа.
Java для главной страницы (первое действие):
public class Hyungs extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hyungs);
final Button ilbuvideo = (Button) findViewById(R.id.il_bu_video);
final Button ilbudiagram = (Button) findViewById(R.id.il_bu_text);
final Button eebuvideo = (Button) findViewById(R.id.ee_bu_video);
final Button eebudiagram = (Button) findViewById(R.id.ee_bu_text);
final ImageView imageview = findViewById(R.id.il_bu_image);
Fade fade = new Fade();
View decor = getWindow().getDecorView();
fade.excludeTarget(decor.findViewById(R.id.youtube_view), true);
getWindow().setEnterTransition(fade);
ilbuvideo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Hyungs.this, IlBuVideo.class);
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(Hyungs.this,
imageview, ViewCompat.getTransitionName(imageview));
startActivity(intent, options.toBundle());
}
});
ilbudiagram.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Hyungs.this, IlBuDiagram.class);
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(Hyungs.this,
imageview, ViewCompat.getTransitionName(imageview));
startActivity(intent, options.toBundle());
}
});
XML для видео страницы (я не поместил ничего в файл Java, относящийся к переходу):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/il_bu_image"
android:layout_width="200dp"
android:layout_marginTop="6dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:transitionName="ilbutransition"
android:adjustViewBounds="true"
android:src="@drawable/white_belt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="Ki Cho Hyung Il Bu"
android:textSize="24dp"
android:textColor="#000000"
android:layout_gravity="center_horizontal"
>
</TextView>
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtube_view"
android:layout_marginTop="16dp"
android:layout_marginBottom="26dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:id="@+id/il_bu_notes"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_below="@+id/youtube_view"
android:text="Note: This video shows low block and centre punches
instead of the front kick phase, otherwise the rest of the video is
the same as LMAC. Please follow the text page to view the correct
LMAC style."
android:textSize="18dp"/>
Я очень новичок в кодировании и до сих пор собирал приложение без особых проблем. Любая помощь очень ценится:)