如何自定义JieCaoVedio的UI?

qq_36394100 2019-04-05 01:07:02
看不太懂,自己弄了下,结果起不来,求大神帮我看看。
首先是我自定义的继承JCVideoPlayer的类
public class MyVedioPlayer extends JCVideoPlayer {

public MyVedioPlayer(Context context) { super(context); }
public MyVedioPlayer(Context context, AttributeSet attrs){super(context, attrs);}

@Override
public void init(Context context) {
super.init(context);
View.inflate(context, getLayoutId(), this);
startButton = (ImageView) findViewById(R.id.start);//开始
textureViewContainer = (ViewGroup) findViewById(R.id.surface_container);//SurfaceView的容器
startButton.setOnClickListener(this);
textureViewContainer.setOnClickListener(this);
textureViewContainer.setOnTouchListener(this);
mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
mScreenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mHandler = new Handler();

}

@Override
public int getLayoutId() {
return R.layout.jc_layout_standard;//自定义的布局文件
}

然后是我自定义的布局文件:

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

<RelativeLayout
android:id="@+id/surface_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

</RelativeLayout>

<ProgressBar
android:id="@+id/loading"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminateDrawable="@drawable/jc_loading"
android:visibility="invisible" />

<ImageView
android:id="@+id/start"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:src="@drawable/jc_click_play_selector" />
</RelativeLayout>

布局文件就是删除了我不想要的,就留了一个开始按钮和processBar

然后是RecyclerViewApapt中引用:

View view = LayoutInflater.from(context).inflate(R.layout.vedioview, viewGroup,false);//这句报错

vedioview就是引用我自定定义的MyVedioPlayer的布局文件,里面就一个MyVedioPlayer。但是就是这里报错

Binary XML file line #7: Binary XML file line #7: Error inflating class com.XXX.MyVedioPlayer
...全文
81 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_36394100 2019-04-05
  • 打赏
  • 举报
回复
不知道是不是继承的JCVideoPlayer 里面有这两个错误,所以不行 public static void hideSupportActionBar(Context context) { if (ACTION_BAR_EXIST) { ActionBar ab = JCUtils.getAppCompActivity(context).getSupportActionBar(); if (ab != null) { ab.setShowHideAnimationEnabled(false); //报错ActionBar.setShowHideAnimationEnabled can only be called from // within the same library group (groupId=com.android.support) ab.hide(); } } if (TOOL_BAR_EXIST) { JCUtils.getAppCompActivity(context).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } } public static void showSupportActionBar(Context context) { if (ACTION_BAR_EXIST) { ActionBar ab = JCUtils.getAppCompActivity(context).getSupportActionBar(); if (ab != null) { ab.setShowHideAnimationEnabled(false);//这里报错和上面一样 ab.show(); } } if (TOOL_BAR_EXIST) { JCUtils.getAppCompActivity(context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } 但是这是人家写好的,我就是把jcvideoplayer-lib当作libiary引到了我的工程,并且把build.gradle改成和我一样的版本号

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧