How to get hardware key option to center of screen

假如想象 提交于 2019-12-25 14:48:28

问题


How to get the pause play forward button option to center of the screen in MediaPlayer but by default it shows at the bottom of the screen.

Here I am using videoView in fullscreen

XML:

<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="match_parent"


    <VideoView
        android:id="@+id/media_video_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
    />
</RelativeLayout>

below i had updated my answer which i had tried and got solution for this please have look at it.


回答1:


You can use custom MediaController or set it position by

mediaController.setPadding(0, 0, 0, px); 

Refer this

You can also use setAnchorView which will reposition controller below particular anchor view, but in your case that won't be possible.

Hope this helps.




回答2:


we can get key options any where in the fullscreen in videoview by below:

DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics();
        int screenWidthPx = (metrics.widthPixels);
     int screenHeightPx = (metrics.heightPixels);
 MediaController mediaController = new MediaController(Activity.this);
  mediaController.setPadding(0, 0, 0, screenHeightPx );

screenHeightPx : you can adjust it where ever you want in the screen.

Hope this helps.



来源:https://stackoverflow.com/questions/27099882/how-to-get-hardware-key-option-to-center-of-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!