Bind mediacontroller to the certain view

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Bind mediacontroller to the certain view



I have next views in activity:


<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20sp"/>

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="40dp" />
</LinearLayout>
</ScrollView>



This activity has a lot of text so in can scroll. I tried to set view as a anchor for the mediacontroller but mediacontroller is always positioned at the screen bottom (even while scrolling).


view


View view = findViewById(R.id.view);
controller.setAnchorView(view);



My question is how to bind mediacontroller to a view so it can scroll with view.


view


view




1 Answer
1



Instead of using view you can use videoview. You can add media controller to videoview. Also it will scroll with scrollview.



Use below code it works.


<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusableInTouchMode="true"
android:focusable="true"
android:descendantFocusability="blocksDescendants">

<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/xyzString"
android:textSize="20sp" />

<VideoView
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:focusable="true"/>
</LinearLayout>
</ScrollView>





It is still at the bottom
– Dzianis
Aug 8 at 7:44





can you explain diagramatically what exactly you want? As you have taken linear layout, it will be placed after text only.
– divaPrajapati09
Aug 8 at 9:28





Yes I want mediacontroller to position in the fixed place (inside view). So when view is not seen on screen (because of large text for instance) mediacontroller also is not seen. When scroll down mediacontroller appears with view.
– Dzianis
Aug 8 at 10:42





updated my answer with code. hope it helps!!
– divaPrajapati09
Aug 8 at 11:33





thanks, it is very helpful answer, but I decided to create custom mediacontroller instead
– Dzianis
Aug 8 at 17:21






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard