Android 实现视频字幕Subtitle和横竖屏切换示例

系统自带的VideoView有些视频格式不支持,那么我们可以用第三方实现的VideoView替代系统的来播放视频,比较流行的有ijkplayervitamio

最近有个需求就是需要给视频添加字幕,其实也挺简单的。字幕比较常用的格式是srt,实际它就是文本,把它解析出来,然后根据时间再展示就OK。还有就是实现了即使旋转按钮关闭,根据方向感应器也能做到横竖屏切换。

本文用的是系统VideoView,然后播放sd卡中的视频来作为演示(源码中带有f2.mp4和f2.srt,运行时拷贝到sd卡就行)。下面简单介绍一下源码:

MainActivity包括显示字幕和如何实现横竖屏如何切换:

public class SubtitleActivity extends Activity implements View.OnClickListener,OnTouchListener{
	private VideoView videoView ;
	TextView tvSrt, mCurrentTime,mTotalTime,resolution_switch,mediacontroller_file_name;
	ImageView mediacontroller_play_pause,switch_screen;
	private SeekBar progress_seekbar;
	private AudioManager mAM;
	private long totalDuration;
	private boolean mShowing = true, mDragging,isResolution;
	private static final int PARSE_SRT = 0;
	private static final int FADE_OUT = 1;
	private static final int SHOW_PROGRESS = 2;
	private static final int CHANGE_VIDEOVIEW_BG = 3;
	private static final int SCREEN_ORIENTATION_USER = 4;
	private static final int sDefaultTimeout = 3000;
	private RelativeLayout videoview_layout, mMediaController;
	private ListView resolution_listview;
	private boolean isPortraint = true;
	private static int LockScreen = -1;// 用于记录是否关闭屏幕旋转,0为关闭1为开启
	private int screenWidth,videoViewHeight;
	List<VideoPathObject> videopathList=new ArrayList<VideoPathObject>();
	Handler mHandler=new Handler(){
		public void handleMessage(Message msg){
			long pos;
			switch (msg.what) {
				case PARSE_SRT:
					SrtParser.showSRT(videoView,tvSrt) ;
				//每隔500ms执行一次showSRT(),根据时间匹配显示哪句字幕
					mHandler.sendEmptyMessageDelayed(0, 500);
					break;
				case FADE_OUT:
					showOrHideController();
					break;
				case SHOW_PROGRESS:
					pos = setControllerProgress();
					if (!mDragging && mShowing) {
						msg = obtainMessage(SHOW_PROGRESS);
					sendMessageDelayed(msg, 1000 - (pos % 1000));
					}
					break;
				case CHANGE_VIDEOVIEW_BG:
					videoView.setBackgroundColor(0x00000000);
					break;
			}
		}
	};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_subtitle);
		videoView = (VideoView)this.findViewById(R.id.videoView );
		mAM = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
		screenWidth = APPApplication.screenWidth;
		videoViewHeight = screenWidth * 9 / 16;
		tvSrt = (TextView)findViewById(R.id.srt);//项目中显示字幕的控件
	mediacontroller_file_name= (TextView)findViewById(R.id.mediacontroller_file_name);
//		String[]splitStr=Constant.videoUrl1.split("/");
//		mediacontroller_file_name.setText(splitStr[splitStr.length-1]);
		mTotalTime = (TextView) findViewById(R.id.mediacontroller_time_total);
		mCurrentTime = (TextView) findViewById(R.id.mediacontroller_time_current);
		resolution_switch = (TextView) findViewById(R.id.resolution_switch);
	mediacontroller_play_pause = (ImageView) findViewById(R.id.mediacontroller_play_pause);
		switch_screen = (ImageView) findViewById(R.id.switch_screen);
		videoview_layout = (RelativeLayout) findViewById(R.id.videoview_layout);
		mediacontroller_play_pause.setOnClickListener(this);
		progress_seekbar = (SeekBar) findViewById(R.id.mediacontroller_seekbar);
		videoview_layout = (RelativeLayout) findViewById(R.id.videoview_layout);
		mMediaController = (RelativeLayout) findViewById(R.id.media_controller);
		resolution_listview = (ListView) findViewById(R.id.resolution_listview);
		resolution_switch.setOnClickListener(this);
		videoView.setOnTouchListener(this);
		progress_seekbar.setOnSeekBarChangeListener(mSeekListener);
		LayoutParams params = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, videoViewHeight);
		videoview_layout.setLayoutParams(params);
		try {
	// 1代表开启自动旋转true,0代表未开启自动旋转false
	// Settings.System.getInt(mContext.getContentResolver(),Settings.System.ACCELEROMETER_ROTATION,0);
		LockScreen = Settings.System.getInt(getContentResolver(),
					Settings.System.ACCELEROMETER_ROTATION);
		} catch (SettingNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		String rawUri = "android.resource://" + getPackageName() + "/" + R.raw.renwei;
		Uri uri = Uri.parse(Constant.videoUrl1);
		//设置视频控制器
// videoView.setMediaController(new MediaController(this));
		//播放完成回调
		videoView.setOnCompletionListener( new MyPlayerOnCompletionListener());
		videoView.setOnPreparedListener(new OnPreparedListener() {
			//@Override
			public void onPrepared(MediaPlayer mp) {
				totalDuration=videoView.getDuration();
				if (mTotalTime != null)
			mTotalTime.setText("/"+generateTime(totalDuration));
			}
		});
		//设置视频路径
		videoView.setVideoURI(uri);
		//开始播放视频
		videoView.start();
		SrtParser.parseSrt(this);
		SrtParser.showSRT(videoView,tvSrt) ;
		mHandler.sendEmptyMessageDelayed(0, 500);
		initVideoResolution();
	}
	private void initVideoResolution(){
		VideoPathObject object1=new VideoPathObject();
		object1.videoStatus="超清";
		videopathList.add(object1);
		VideoPathObject object2=new VideoPathObject();
		object2.videoStatus="高清";
		videopathList.add(object2);
		VideoPathObject object3=new VideoPathObject();
		object3.videoStatus="标清";
		videopathList.add(object3);
		switchResolution(videopathList);
	}
	class MyPlayerOnCompletionListener implements MediaPlayer.OnCompletionListener {
		@Override
		public void onCompletion(MediaPlayer mp) {
	Toast.makeText( SubtitleActivity.this, "播放完成了", Toast.LENGTH_SHORT).show();
		}
	}
	private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
		public void onStartTrackingTouch(SeekBar bar) {
			mDragging = true;
			mHandler.removeMessages(SHOW_PROGRESS);
			mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
		}
		public void onProgressChanged(SeekBar bar, int progress,
		 boolean fromuser) {
			if (!fromuser)
				return;
			int newposition = (int)(totalDuration * progress) / 1000;
			String time = generateTime(newposition);
			videoView.seekTo(newposition);
			mCurrentTime.setText(time);
		}
		public void onStopTrackingTouch(SeekBar bar) {
			videoView.seekTo(((int)totalDuration * bar.getProgress()) / 1000);
			hideMediaController(sDefaultTimeout);
			mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
			mDragging = false;
			mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
		}
	};
	private void switchResolution(final List<VideoPathObject> videopathList) {
		resolution_switch
	.setText(videopathList.get(videopathList.size() - 1).videoStatus);
		mediacontroller_play_pause.setImageResource(R.drawable.player_play);
		final ResolutionAdapter adapter = new ResolutionAdapter(videopathList,
				SubtitleActivity.this);
		resolution_listview.setAdapter(adapter);
		resolution_listview
		.setOnItemClickListener(new AdapterView.OnItemClickListener() {
		@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
											int position, long arg3) {
				// TODO Auto-generated method stub
//				// currentPosition = videoView.getCurrentPosition();
//				currentPosition = videoView.getCurrentPosition();
//				Log.d("gaolei", "currentPosition---------1------"
//								+ currentPosition);
				VideoPathObject pathObject = videopathList
								.get(position);
////				playVideo(pathObject.videoUrl);
//				adapter.changePosition(position);
				resolution_switch.setText(pathObject.videoStatus);
				resolution_listview.setVisibility(View.GONE);
					}
				});
	}
	public void showOrHideController() {
		if (mShowing) {
			mHandler.removeMessages(SHOW_PROGRESS);
			mHandler.removeMessages(FADE_OUT);
			mMediaController.setVisibility(View.GONE);
			resolution_listview.setVisibility(View.GONE);
			mShowing = false;
		} else {
			mHandler.sendEmptyMessage(SHOW_PROGRESS);
			mMediaController.setVisibility(View.VISIBLE);
			hideMediaController(sDefaultTimeout);
			mShowing = true;
		}
	}
	public void hideMediaController(int sDefaultTimeout) {
		mHandler.sendEmptyMessageDelayed(FADE_OUT, sDefaultTimeout);
	}
	private long setControllerProgress() {
		if (videoView == null || mDragging)
			return 0;
		int position = videoView.getCurrentPosition();
		if (progress_seekbar != null) {
			if (totalDuration > 0) {
				long pos = 1000L * position / totalDuration;
				// Log.d("gaolei", "progress--------------" + pos);
				progress_seekbar.setProgress((int) pos);
			}
			int percent = videoView.getBufferPercentage();
			progress_seekbar.setSecondaryProgress(percent * 10);
		}
		if (mCurrentTime != null)
			mCurrentTime.setText(generateTime(position));
		return position;
	}
	private static String generateTime(long position) {
		int totalSeconds = (int) (position / 1000);
		int seconds = totalSeconds % 60;
		int minutes = (totalSeconds / 60) % 60;
		int hours = totalSeconds / 3600;
		if (hours > 0) {
			return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes,
					seconds).toString();
		} else {
			return String.format(Locale.US, "%02d:%02d", minutes, seconds)
					.toString();
		}
	}
	private void updatePausePlay() {
		if (videoView.isPlaying()) {
			videoView.pause();
			mediacontroller_play_pause
					.setImageResource(R.drawable.player_pause);
		} else {
			videoView.start();
			mediacontroller_play_pause.setImageResource(R.drawable.player_play);
		}
	}
	public void showResolution(View view) {
		if (!isResolution) {
			resolution_listview.setVisibility(View.VISIBLE);
			isResolution = true;
		} else {
			resolution_listview.setVisibility(View.GONE);
			isResolution = false;
		}
	}
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
			changeToFullScreen();
			Log.d("gaolei", "ORIENTATION_LANDSCAPE-------------");
		}
		if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
			changeToSmallScreen();
			Log.d("gaolei", "ORIENTATION_PORTRAIT-------------");
		}
	}
	public void switchScreen(View view) {
		if (isPortraint) {
			handToFullScreen();
		} else {
			handToSmallScreen();
		}
	}
	public void handToSmallScreen() {
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
		changeToSmallScreen();
		/**
		 * 这里点击按钮转屏,用户5秒内不转屏幕,将自动识别当前屏幕方向
		 */
		autoSwitchScreenOrientation();
	}
	public void handToFullScreen() {
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
		changeToFullScreen();
		autoSwitchScreenOrientation();
	}
	private void changeToFullScreen() {
		isPortraint = false;
		LayoutParams params = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, APPApplication.screenWidth);
		videoview_layout.setLayoutParams(params);
		videoView.setLayoutParams(params);
		WindowManager.LayoutParams windowparams = getWindow().getAttributes();
		windowparams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
		getWindow().setAttributes(windowparams);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
		switch_screen.setImageResource(R.drawable.player_switch_small);
	}
	private void changeToSmallScreen() {
		isPortraint = true;
		LayoutParams params = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, videoViewHeight);
		videoview_layout.setLayoutParams(params);
		videoView.setLayoutParams(params);
		WindowManager.LayoutParams windowparams = getWindow().getAttributes();
		windowparams.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
		getWindow().setAttributes(windowparams);
		getWindow()
				.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
		switch_screen.setImageResource(R.drawable.player_switch_big);
	}
	public void autoSwitchScreenOrientation() {
//		手动旋转屏幕,5s后会执行感应的方向
		new Timer().schedule(new TimerTask() {
			@Override
			public void run() {
			// TODO Auto-generated method stub
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
			Log.d("gaolei", "SCREEN_ORIENTATION_FULL_SENSOR");				}
		}, 5000);
	}
	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN: {
				showOrHideController();
				break;
			}
		}
		return false;
	}
	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		switch(view.getId()){
			case R.id.mediacontroller_play_pause:
				Log.d("gaolei", "mediacontroller_play_pause");
				updatePausePlay();
				break;
			case R.id.resolution_switch:
				resolution_listview.setVisibility(View.VISIBLE);
				break;
		}
	}
	public void jumpToMain(View view){
		startActivity(new Intent(this, MainActivity.class));
	}
	public void onRestart(){
		super.onRestart();
		videoView.start();
		mediacontroller_play_pause.setImageResource(R.drawable.player_play);
	}
	public void onStop(){
		super.onStop();
		videoView.pause();
		mediacontroller_play_pause.setImageResource(R.drawable.player_pause);
	}
}

SrtParser就是解析字幕文件的算法:

public class SrtParser {
 public static ArrayList<SRT>srtList;
 public static int lastEndTime;
 /**
 * 解析SRT字幕文件
 * 字幕路径
 */
 public static void parseSrt(Context context) {
 InputStream inputStream = null;
 try {
//  inputStream=context.getResources().openRawResource(R.raw.renwei2);
  inputStream = new FileInputStream(Constant.srtUrl1);
  // TODO Auto-generated catch block
  BufferedReader br = new BufferedReader(new InputStreamReader(
   inputStream,"GB2312"));
  String line = null;
  srtList = new ArrayList<SRT>();
  StringBuffer sb = new StringBuffer();
  while ((line = br.readLine()) != null) {
  // Log.d("gaolei", "br.readLine()-----------"+br.readLine());
  if (!line.equals("")) {
   Log.d("gaolei","line-------------------"+ line);
   sb.append(line).append("@");
   continue;
  }
  Log.d("gaolei", "sb.toString()-----------"+sb.toString());
  String[] parseStrs = sb.toString().split("@");
  // 该if为了适应一开始就有空行以及其他不符格式的空行情况
  if (parseStrs.length < 3) {
   sb.delete(0, sb.length());// 清空,否则影响下一个字幕元素的解析</i>
   continue;
  }
  SRT srt = new SRT();
  // 解析开始和结束时间
  String timeTotime = parseStrs[1];
  int begin_hour = Integer.parseInt(timeTotime.substring(0, 2));
  int begin_mintue = Integer.parseInt(timeTotime.substring(3, 5));
  int begin_scend = Integer.parseInt(timeTotime.substring(6, 8));
  int begin_milli = Integer.parseInt(timeTotime.substring(9, 12));
  int beginTime = (begin_hour * 3600 + begin_mintue * 60 + begin_scend)
   * 1000 + begin_milli;
  int end_hour = Integer.parseInt(timeTotime.substring(17, 19));
  int end_mintue = Integer.parseInt(timeTotime.substring(20, 22));
  int end_scend = Integer.parseInt(timeTotime.substring(23, 25));
  int end_milli = Integer.parseInt(timeTotime.substring(26, 29));
  int endTime = (end_hour * 3600 + end_mintue * 60 + end_scend)
   * 1000 + end_milli;
  System.out.println("开始:" + begin_hour + ":" + begin_mintue +
   ":"
   + begin_scend + ":" + begin_milli + "=" + beginTime
   + "ms");
  System.out.println("结束:" + end_hour + ":" + end_mintue + ":"
   + end_scend + ":" + end_milli + "=" + endTime + "ms");
  // 解析字幕文字
  String srtBody = "";
  // 可能1句字幕,也可能2句及以上。
  for (int i = 2; i < parseStrs.length; i++) {
   srtBody += parseStrs[i]+ "\n";
  }
  // 删除最后一个"\n"
  srtBody = srtBody.substring(0, srtBody.length() - 1);
  // 设置SRT
  srt.setBeginTime(beginTime);
  srt.setEndTime(endTime);
  srt.setSrtBody(new String(srtBody.getBytes(), "UTF-8"));
  srtList.add(srt);
  sb.delete(0, sb.length());// 清空,否则影响下一个字幕元素的解析
  }
  lastEndTime=srtList.get(srtList.size()-1).getEndTime();
  br.close();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
 //每隔500ms执行一次()取
 }
 public static void showSRT(VideoView videoView,TextView tvSrt) {
// 	Log.d("gaolei", "srt_map.size()--------------"+srt_map.size());
 int currentPosition = videoView.getCurrentPosition();//vv是VideoView播放器
 if(currentPosition>lastEndTime){
  tvSrt.setVisibility(View.GONE);
  return;
 }
 for(int i=0;i<srtList.size();i++){
  SRT srtbean =srtList.get(i);
  if (currentPosition > srtbean.getBeginTime()
   && currentPosition < srtbean.getEndTime()) {
  tvSrt.setText(srtbean.getSrtBody());
  //显示过的就删掉,提高查询效率
  srtList.remove(i);
  break;//找到后就没必要继续遍历下去,节约资源
  }
 }
 }
}

运行效果图:

项目源码,点击下载......

以上这篇Android 实现视频字幕Subtitle和横竖屏切换示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。

您可能感兴趣的文章:

  • Android重力传感器实现滚动的弹球
  • Android 重力传感器在游戏开发中的应用
  • Android开发中的重力传感器用法实例详解
  • 解析Android横竖屏切换的问题
  • Android横竖屏幕切换小结
  • Android实现横竖屏切换的实例代码
  • Android横竖屏切换实例总结
  • 解决Android手机屏幕横竖屏切换
  • Android横竖屏幕切换生命周期详解
  • Android编程基于重力传感器实现横竖屏放向切换功能
(0)

相关推荐

  • Android重力传感器实现滚动的弹球

    熟知: 什么是传感器: 所谓传感器能够探测如光.热.温度.重力.方向 等等的功能! Android中提供传感器有哪些: 1.  加速度传感器(重力传感器)      2.  陀螺仪传感器      3.  光传感器      5.  恒定磁场传感器      6.  方向传感器      7.  恒定的压力传感器      8.  接近传感器      9.  温度传感器 一. 问题描述 Android中有多达11种传感器,不同的手机设备支持的传感器类型也不尽相同 1. 重力传感器 GV-sen

  • 解决Android手机屏幕横竖屏切换

    Android中当屏幕横竖屏切换时,Activity的生命周期是重新加载(说明当前的Activity给销毁了,但又重新执行加载), 怎么使屏幕横竖屏切换时,当前的Activity不销毁呢? 1. 在AndroidManifest.xml中为Activity设置configChanges属性, application android:icon="@drawable/icon" android:label="@string/app_name"> <activ

  • 解析Android横竖屏切换的问题

    在做android 开发时,在默认情况下当屏幕从竖评变到横屏时会触发 onConfigurationChanged 事件 在默认情况下会重新加载画面并显示和横评一样的画面,这样会有2个问题,布局问题,在竖屏 显示的布局到横屏中由于宽和高发生了变化所有多少都会影响到布局(除非你定制2套画面在然后加个判断在横屏时怎么显示,在竖屏时怎么显示),当然最简单的办法就是在项目的 AndroidManifest.xml中找到你所指定的activity 中加上 只竖屏显示的话(android:screenOri

  • Android横竖屏切换实例总结

    本文实例总结了Android横竖屏切换相关技巧.分享给大家供大家参考,具体如下: 一.禁止横竖屏切换 Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换,即通过在AndroidManifest.xml中设置activity中的android:screenOrientation属性值来实现. 该android:screenOrientation属性,他有以下几个参数: "unspecified":默认值 由系统来

  • Android横竖屏幕切换小结

    Android手机或平板都会存在横竖屏切换的功能,通常是由物理重力感应触发的,但是有时候也不尽然,通常在设置里面我们可以对手机的横竖屏切换进行关闭. AndroidManifest.xml <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|

  • Android横竖屏幕切换生命周期详解

    一.简介 二.代码 /activityLifeCycle_3Screen/AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.fry.activityLifeCycle_3Screen" android:versionCode="1" android:versionName="1.

  • Android实现横竖屏切换的实例代码

    这几年一直在做手机上和电视盒的App,几乎没有考虑过横竖屏切换的问题.电视盒好说,横屏不变,你要是给它设计个竖屏人家也没机会使:而手机上的应用就不好说了,有些界面你设计了横竖屏兼容可能是为了表示你的功能强大.但是按照惯例,或许也是设计师图省事,我们只是做一个方案.就像目前主流的App都只有竖屏一个模式,比如微信.京东和招商银行.我截了几张图表示一下. 但是像地图之类的应用,也许横屏会显示的更友好一些.请看腾讯地图的设计如下: 细心的你会发现,地图的横竖屏的样式几乎是一样的布局,调整起来还是比较容

  • Android 重力传感器在游戏开发中的应用

    手势操作可以说是智能手机的一种魅力所在,前两节给大家讲解了两种有趣的手势操作,将它们置于游戏当中,大大提升了游戏的可玩性和趣味性.本节将继续介绍智能手机的另一种神奇之处:传感器.    一.何为传感器 所谓传感器就是能够探测如光.热.温度.重力.方向等等的装置.    二.Android提供了哪些传感器 1.加速度传感器(重力传感器) 2.陀螺仪传感器 3.光传感器 4.恒定磁场传感器 5.方向传感器 6.恒定的压力传感器 7.接近传感器 8.温度传感器 今天我们给大家介绍的是游戏开发中最最常见

  • Android开发中的重力传感器用法实例详解

    本文实例讲述了Android开发中的重力传感器用法.分享给大家供大家参考,具体如下: 重力传感器与方向传感器的开发步骤类似,只要理清了期中的x,y,z的值之后就可以根据他们的变化来进行编程了,首先来看一副图 假设当地的重力加速度值为g 当手机正面朝上的时候,z的值为q,反面朝上的时候,z的值为-g 当手机右侧面朝上的时候,x的值为g,右侧面朝上的时候,x的值为-g 当手机上侧面朝上的时候,y的值为g,右侧面朝上的时候,y的值为-g 了解了重力传感器中X,Y,Z的含义之后下面我们就开始学习如何使用

  • Android编程基于重力传感器实现横竖屏放向切换功能

    本文实例讲述了Android编程基于重力传感器实现横竖屏放向切换功能.分享给大家供大家参考,具体如下: 最近项目中用到了vr视频播放,因为自己实现,同时要实现横竖屏自动切换屏幕,核心代码如下: package com.d1ev.touch.App.helper; import android.app.Activity; import android.content.pm.ActivityInfo; import android.util.Log; import android.view.Orie

随机推荐