第三方实用控件 未完待续
来源:互联网 发布:经传软件指标全集 编辑:程序博客网 时间:2024/04/30 14:09
底部导航栏 BottomTabBar
导入依赖 compile 'com.hjm:BottomTabBar:1.1.1'
实现ViewPager 和 Fragment的 联动 主要是一个 初始化方法 在XML 中 可以 定义一些属性.
具体网址::http://blog.csdn.net/qiaoshi96_bk/article/details/73716310
垂直广告轮播 VerticalBannerView
有点特殊的就是需要在总的Build.gradle加一句
maven {
url "https://jitpack.io"
}
compile 'com.github.Rowandjj:VerticalBannerView:1.0'
具体使用网址:http://blog.csdn.net/Android_Sunshine_Sun/article/details/78318137
MainActivity 代码
导入依赖 compile 'com.hjm:BottomTabBar:1.1.1'
实现ViewPager 和 Fragment的 联动 主要是一个 初始化方法 在XML 中 可以 定义一些属性.
具体网址::http://blog.csdn.net/qiaoshi96_bk/article/details/73716310
垂直广告轮播 VerticalBannerView
有点特殊的就是需要在总的Build.gradle加一句
maven {
url "https://jitpack.io"
}
compile 'com.github.Rowandjj:VerticalBannerView:1.0'
具体使用网址:http://blog.csdn.net/Android_Sunshine_Sun/article/details/78318137
倒计时 秒杀 定时器
https://github.com/iwgang/CountdownView/blob/master/README_CN.md
代码很少
视频播放器 第三方的 功能强大
compile 'com.linsea:universalvideoview:1.1.0@aar'
XML代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:id="@+id/video_layout" android:layout_width="fill_parent" android:layout_height="200dp" android:background="@android:color/black"> <com.universalvideoview.UniversalVideoView android:id="@+id/videoView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" app:uvv_autoRotation="true" app:uvv_fitXY="false" /> <com.universalvideoview.UniversalMediaController android:id="@+id/media_controller" android:layout_width="fill_parent" android:layout_height="fill_parent" app:uvv_scalable="true" /> </FrameLayout> <LinearLayout android:id="@+id/bottom_layout" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <Button android:id="@+id/start" android:layout_margin="5dp" android:layout_width="fill_parent" android:layout_height="50dp" android:gravity="center" android:text="start" /> <TextView android:id="@+id/introduction" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:text="介绍" android:background="@color/uvv_gray" /> </LinearLayout></LinearLayout>
MainActivity 代码
public class MainActivity extends AppCompatActivity implements UniversalVideoView.VideoViewCallback{ private static final String TAG = "MainActivity"; private static final String SEEK_POSITION_KEY = "SEEK_POSITION_KEY"; private static final String VIDEO_URL = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; UniversalVideoView mVideoView; UniversalMediaController mMediaController; View mBottomLayout; View mVideoLayout; TextView mStart; private int mSeekPosition; private int cachedHeight; private boolean isFullscreen; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mVideoLayout = findViewById(R.id.video_layout); mBottomLayout = findViewById(R.id.bottom_layout); mVideoView = (UniversalVideoView) findViewById(R.id.videoView); mMediaController = (UniversalMediaController) findViewById(R.id.media_controller); mVideoView.setMediaController(mMediaController); setVideoAreaSize(); mVideoView.setVideoViewCallback(this); mStart = (TextView) findViewById(R.id.start); mStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mSeekPosition > 0) { mVideoView.seekTo(mSeekPosition); } mVideoView.start(); mMediaController.setTitle("Big Buck Bunny"); } }); mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { Log.d(TAG, "onCompletion "); } }); } @Override protected void onPause() { super.onPause(); Log.d(TAG, "onPause "); if (mVideoView != null && mVideoView.isPlaying()) { mSeekPosition = mVideoView.getCurrentPosition(); Log.d(TAG, "onPause mSeekPosition=" + mSeekPosition); mVideoView.pause(); } } /** * 置视频区域大小 */ private void setVideoAreaSize() { mVideoLayout.post(new Runnable() { @Override public void run() { int width = mVideoLayout.getWidth(); cachedHeight = (int) (width * 405f / 720f);// cachedHeight = (int) (width * 3f / 4f);// cachedHeight = (int) (width * 9f / 16f); ViewGroup.LayoutParams videoLayoutParams = mVideoLayout.getLayoutParams(); videoLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; videoLayoutParams.height = cachedHeight; mVideoLayout.setLayoutParams(videoLayoutParams); mVideoView.setVideoPath(VIDEO_URL); mVideoView.requestFocus(); } }); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.d(TAG, "onSaveInstanceState Position=" + mVideoView.getCurrentPosition()); outState.putInt(SEEK_POSITION_KEY, mSeekPosition); } @Override protected void onRestoreInstanceState(Bundle outState) { super.onRestoreInstanceState(outState); mSeekPosition = outState.getInt(SEEK_POSITION_KEY); Log.d(TAG, "onRestoreInstanceState Position=" + mSeekPosition); } @Override public void onScaleChange(boolean isFullscreen) { this.isFullscreen = isFullscreen; if (isFullscreen) { //这句主要是在 切换 大小屏时 换个标题// mMediaController.setTitle("XXX"); ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; mVideoLayout.setLayoutParams(layoutParams); mBottomLayout.setVisibility(View.GONE); } else { ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; layoutParams.height = this.cachedHeight; mVideoLayout.setLayoutParams(layoutParams); mBottomLayout.setVisibility(View.VISIBLE); } switchTitleBar(!isFullscreen); } private void switchTitleBar(boolean show) { android.support.v7.app.ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { if (show) { supportActionBar.show(); } else { supportActionBar.hide(); } } } @Override public void onPause(MediaPlayer mediaPlayer) { Log.d(TAG, "onPause UniversalVideoView callback"); } @Override public void onStart(MediaPlayer mediaPlayer) { Log.d(TAG, "onStart UniversalVideoView callback"); } @Override public void onBufferingStart(MediaPlayer mediaPlayer) { Log.d(TAG, "onBufferingStart UniversalVideoView callback"); } @Override public void onBufferingEnd(MediaPlayer mediaPlayer) { Log.d(TAG, "onBufferingEnd UniversalVideoView callback"); } @Override public void onBackPressed() { if (this.isFullscreen) { mVideoView.setFullscreen(false); } else { super.onBackPressed(); } }}
阅读全文
0 0
- 第三方实用控件 未完待续
- 幻方~未完待续
- 【第三方框架】Glid4.4 完全学习(未完待续)
- 新手上路,一键分享,友盟sdk,不使用第三方sdk(未完待续)
- JAVA开发过程中使用第三方jar(未完待续)
- jQuery很实用的代码,未完待续
- docker实用命令--未完待续
- 封装控件的原理[未完待续]
- 第三方实用库
- 未完待续
- 未完待续
- 未完待续
- 未完,待续
- 未完待续~~~~~~~~~~~~~~~~
- 未完待续
- 未完待续
- 未完待续
- 未完待续
- angularjs的加减数量,确认删除
- [2017年10月24日]考试总结
- 今日错误集锦
- 洛谷P1015回文数
- python实现校园网自动登录
- 第三方实用控件 未完待续
- ecplise 选择工作空间启动出错(java9)
- 【大组会整理】深度生成模型可视化刘世霞深度生成网络可视化
- SylixOS线程创建的流程分析
- (全网最详细!)bzoj 2548 灭鼠行动 模拟 解题报告
- C++对传参和传返回值时构造的优化处理
- 艾伦人工智能研究所CEO Oren Etzioni:深度学习离人类水平的人工智能还差得很远
- Java-数据库
- 从 13 年开发史中,谷歌无人车之父预见自动驾驶的未来