Danke für die Hilfe. Das hat gut für meine App funktioniert. Lass mich erklären, wie ich es endlich geschafft habe. Zu diesem Zweck benötigen wir Relatives Layout, in dem wir die Ansichten überlappen können. Ich habe ImageView und YoutubeView überlappt. Anfangs habe ich ImageView als VISIBLE und youtubeView als INVISIBLE gesetzt. In View.onClickListener für ImageView habe ich ImageView als INVISIBLE und youtubeView als VISIBLE erstellt. Das funktioniert gut für mich.
Hinweis: Das Überlappen von Ansichten ist nur in RelativeLayout möglich, nicht in einem anderen Layout, es sei denn, Sie möchten Ihre eigenen benutzerdefinierten Layouts erstellen.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingStart="@dimen/activity_horizontal_margin_less"
android:paddingRight="@dimen/activity_horizontal_margin_less"
android:paddingTop="@dimen/activity_vertical_margin_less"
android:paddingBottom="@dimen/activity_vertical_margin_less"
tools:context="com.example.puneet.movieout.MovieInfoDisplay"
>
<TextView
android:layout_width="wrap_content"
android:id="@+id/textView2"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="I am Puneet Chugh. I am Puneet Chugh"
android:layout_centerHorizontal="true"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="@color/black"/>
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtube_view"
android:layout_below="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
/>
<ImageView
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/imageView"
android:layout_below="@+id/textView2"/>
</RelativeLayout>
Die Aktivität Teil:
youTubeView.setVisibility(View.INVISIBLE);
moviePoster.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moviePoster.setVisibility(View.INVISIBLE);
youTubeView.setVisibility(View.VISIBLE);
}
});
Danke für deine Antwort. Also, schlagen Sie vor, dass ich Ansichten überschneiden kann? Kann ich ein Bild haben, das verschwindet, wenn ich darauf klicke und das Video erscheint? Und das Video passt in den gleichen Bildraum? –