大家好我想让我的DrawingSurface视图透明.我试了很多东西,但它不起作用.
这是我的表面视图透明的xml代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/icon" >
</ImageView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000" >
<codewalla.android.drawings.DrawingSurface
android:id="@+id/drawingSurface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</codewalla.android.drawings.DrawingSurface>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/colorRedBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="onClick"
android:text="R" />
<Button
android:id="@+id/colorBlueBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="onClick"
android:text="G" />
<Button
android:id="@+id/colorGreenBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="onClick"
android:text="B" />
<Button
android:id="@+id/undoBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="onClick"
android:text="U" />
<Button
android:id="@+id/redoBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:onClick="onClick"
android:text="R" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我们在Android API 4.0上运行了一个Android应用程序.其中一个活动的布局将屏幕分为两部分.在左侧,我们有一个带有一些按钮的静态部分.在右侧,我们有一个FrameLayout,它将根据按下的按钮切换到相应的片段.
问题: 右侧的一个片段包含VideoView.当用户点击按钮以显示该片段时,片段被显示并且视频立即开始播放:在渲染该片段时,整个屏幕以黑色闪烁,这非常烦人.
以下是VideoFragment类的一些代码:
public class VideoFragment extends Fragment {
public VideoView videoView;
private ExternalVideo mVideo;
private boolean mVideoExists;
private String mDestination;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDestination = ApplicationParams.MEDIA_STORAGE_PATH + "videos/"
+ FilenameUtils.getBaseName(((DetailActivity)getActivity()).getProduct().getVideoUrl())
+ "."
+ FilenameUtils.getExtension(((DetailActivity) getActivity()).getProduct().getVideoUrl());
File file = new File(mDestination);
mVideoExists = file.exists() && file.isFile();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view;
if (mVideoExists) {
getActivity().getWindow().setFormat(PixelFormat.TRANSLUCENT);
view = inflater.inflate(R.layout.video, null);
mVideo = new ExternalVideo(mDestination);
videoView = …Run Code Online (Sandbox Code Playgroud) android android-video-player android-layout android-fragments
我正面临着奇怪的闪烁问题VideoView.当活动开始时,它会导致轻微的分数闪烁一秒钟.然后,视频开始.它在视频的顶部和底部显示2条黑线.请参阅下面的快照.

我在2台设备上测试了我的应用程序
1)三星n-8000(平板电脑)
2)联想a-800
video.xml
<?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"
android:gravity="center">
<VideoView
android:id="@+id/vvSplash"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#00ffffff">
</VideoView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
活动代码:
private VideoView vd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video);
vd = (VideoView) findViewById(R.id.vvSplash);
playVideo();
}
private void playVideo() {
Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
vd.setVideoURI(uri);
vd.setMediaController(null);
vd.start();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢.
我正在研究Android的多媒体视频处理应用程序,我遇到了一些问题.我正在使用FragmentPagerAdapter包含许多不同片段的类来进行各种视频处理步骤.
我的第一个Fragment包含一个SurfaceView和一个MediaPlayer它提供它,以及各种播放控件.当我从片段1(使用SurfaceView)滑动到片段2(此时为空)时,我的问题就出现了.如果我还没有打电话start(),没有什么异常发生,我能够正常地在片段之间滑动.start()然而,一旦我打电话,当我滑动到下一个屏幕时,整个屏幕开始闪烁Fragment,即使我已经MediaPlayer处于空闲状态并且它没有输入帧SurfaceView.唯一阻止这种情况的是通过滑动到第三个来破坏表面和包含视图,Fragment以便FragmentPagerAdapter销毁Fragment一个,或者通过主页或后退按钮退出应用程序以便视图被破坏.
我不能为我的生活弄清楚为什么会发生这种情况,除此之外,SurfaceView渲染线程可能会以某种方式干扰主UI线程.LogCat上也没有出现异常,所以我有点卡住了.我正在运行一个带有android 4.1的Galaxy Nexus作为我的测试硬件.
任何帮助,将不胜感激!
JT
更新:我已经设法找到了一个解决方法,现在通过覆盖setPrimaryItem()方法FragmentPagerAdapter来调用一个方法,在视频播放器停止显示时SurfaceView从层次结构中删除(removeView()在其LinearLayout容器上使用)Fragment,然后恢复SurfaceView它的活动时再次.不幸的是,当这种情况发生时仍然有点眨眼,所以如果有人有额外的想法,我将不胜感激!
android flicker surfaceview android-fragments android-mediaplayer
我在CompoundView中使用GLSurfaceView来实现精美的导航.目前,GLSurfaceView是在选择子部分时创建的,而不是在开始时创建的.
我的问题是,当第一次创建GLSurfaceView时,屏幕会瞬间闪烁.选择不同的子部分时,它不会闪烁; 在这种情况下,当前的GLSurfaceView被丢弃,另一个被创建.
当然,这非常令人恼火,特别是因为它在非常轻的主题上闪烁着黑色.我想在大多数情况下它都没关系,因为GLSurfaceViews通常是全屏的并且使用寿命很长,但在这种情况下它是一个传统的Android应用程序,它可以一直打开和关闭活动.
有没有办法规避这个?就像在创建活动时预先初始化OpenGl一样(我假设闪烁在那里不会那么烦人)?
我有谷歌地图片段的错误.片段放在我的活动中,当我打开导航抽屉时,它会显示在地图片段后面.这很奇怪,因为导航抽屉位于布局中片段的顶部.
CameraView也有同样的问题.
在android 2.3和一些上检测到的问题
我想使用 SurfaceView 制作动画来显示实时相机预览。它工作正常。但是当它第一次加载时,它第一次闪烁。