我正在编写一个Android应用程序来构建一个(例如)640*480像素的屏幕外位图,并在SurfaceView中显示它.请注意,图像的大小比手机上的实际显示大.
应用程序的工作方式是它最初显示图像的左上角(0,0),然后我希望能够滚动图像.
我的Surfaceview类实现onMeasure回调并返回1024*768的大小,该大小显示与电话屏幕对应的图像区域.我想实现对滚动的支持,由于文档非常有限(只有一堆类和没有一致性的调用),我发现这几乎是不可能的.我试过只调用scrollBy,但这不起作用.
如果有人有任何关于如何进行的指示,将非常感激.
我有一个在scrollView中的VideoView.当我滚动scrollView时,VideoView不会滚动它.这就像它的位置是固定的.这是我的布局:
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF">
<LinearLayout android:id="@+id/BackBar" android:orientation="vertical" android:layout_width="fill_parent" android:paddingTop="2dp" android:layout_height="wrap_content" android:background="#D6DEAA">
<Button android:id="@+id/BackButton" android:layout_gravity="left" android:text="@string/BackButtonText" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<ScrollView android:id="@+id/scroll1" android:layout_height="fill_parent" android:layout_width="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF">
<LinearLayout android:id="@+id/contentVideo" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="30px" android:paddingTop="15px" android:background="#FFFFFF">
<TextView android:id="@+id/learn_hiv_blck1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/learn_hiv_blck1" android:textColor="#000000" android:textStyle="italic" android:background="#FFFFFF" android:layout_gravity="left" />
<TextView android:id="@+id/learn_hiv_blck2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="15px" android:text="@string/learn_hiv_blck2" android:textColor="#000000" android:background="#FFFFFF" android:layout_gravity="left" />
<TextView android:id="@+id/learn_hiv_blck3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="15px" android:text="@string/learn_hiv_blck3" android:textColor="#000000" android:background="#FFFFFF" android:layout_gravity="left" />
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF">
<VideoView android:id="@+id/VideoView" …Run Code Online (Sandbox Code Playgroud) 首先,我想指出Android中似乎有一个限制,其中有一个SurfaceViewon ScrollView不能像你期望的那样工作.这在这里解释
(内部VideoView使用,SurfaceView所以它有这个问题).但似乎是一个解决方法为VideoView它为我工作.
现在,我还想使用新的Android API for Android在我们的Android应用中显示嵌入的YouTube视频.的YouTubePlayerView作为层次结构中的观看者示出低于其也实现了嵌入式视频播放器呈现以上,因为它使用一个SurfaceView提到的问题.

我无法找到解决此问题的方法.有一个YouTubePlayerView上ScrollView是一个相当普遍的情况下使用我们的应用程序(也可能是其他许多人太).我将不胜感激任何评论.
我已经用谷歌搜索了很多来解决这个问题,但是在任何情况下都行不通。尝试了具有videoview 的ScrollView和Android Scrollview 内的Android :: VideoView中提到的所有操作,都出现了问题。
问题是当我将视频视图放入scrollview时不起作用,但是当删除scrollview时,它确实可以正常工作。
这是示例代码:
// xml file
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/btn_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start" />
<ScrollView
android:id="@+id/scrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_video" >
<VideoView
android:id="@+id/videoView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
和Java代码,MainActivity类
package com.practice.videoviewexample;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;
import android.widget.VideoView;
public class MainActivity extends Activity {
private VideoView videoView_exhibit;
private Button btnVideo;
@Override
protected void …Run Code Online (Sandbox Code Playgroud)