前言
PreviewSeekBar的使用。
适合用于显示预览是SeekBar。如在谷歌播放的电影。 Google Play Movies如下:
PreviewSeekBar's sample如下:
Build
dependencies {
compile 'com.github.rubensousa:previewseekbar:0.3'
}
How to use Add the following XML:
<com.github.rubensousa.previewseekbar.PreviewSeekBarLayout
android:id="@+id/previewSeekBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/previewFrameLayout"
android:layout_width="@dimen/video_preview_width"
android:layout_height="@dimen/video_preview_height">
<View
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorPrimary" />
</FrameLayout>
<com.github.rubensousa.previewseekbar.PreviewSeekBar
android:id="@+id/previewSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/previewFrameLayout"
android:layout_marginTop="25dp"
android:max="800" />
</com.github.rubensousa.previewseekbar.PreviewSeekBarLayout>
你需要添加至少一个PreviewSeekBar 或者FrameLayout在PreviewSeekBarLayout,否则将抛出一个异常。
Pass a standard OnSeekBarChangeListener to the seekBar:
// setOnSeekBarChangeListener was overridden to do the same as below
seekBar.addOnSeekBarChangeListener(this);
Implement your own preview logic in:
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// I can't help anymore
}