To alternate between using the Google Map fragment and VideoView within a single Activity, you can use a layout that contains both views and switch between them programmatically.
Here's an example of how to do this:
<RelativeLayout
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</RelativeLayout>
private SupportMapFragment mapFragment;
private VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize the map fragment and video view
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
videoView = findViewById(R.id.video_view);
// Set up any necessary callbacks or listeners here
}
// Show the map view and hide the video view
mapFragment.getView().setVisibility(View.VISIBLE);
videoView.setVisibility(View.GONE);
// Show the video view and hide the map view
mapFragment.getView().setVisibility(View.GONE);
videoView.setVisibility(View.VISIBLE);
By switching the visibility of the two views programmatically, you can alternate between using the Google Map fragment and VideoView as needed in your app.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-04-13 11:00:00 +0000
Seen: 9 times
Last updated: Aug 09 '22
How can a ListView be utilized in a ScrollView without a Scrollbar?
How can I detect when someone clicks outside of an Android Compose ModalBottomSheetLayout?
What is the process to activate the screen time off feature in Android using AOSP customization?
What is the proper way to rotate the View Component in React Native for Android?
What is the process of using the Volley library to upload a file on Android?
Is it not possible to set another activity as the main activity in Android Studio?
How can I utilize xml to implement a color filter on an ImageView?