如何在水平视图中向背景添加动画?
How add animation to a background in horizontal view?
我在水平视图背景中添加了蓝色!但是我需要在布局中添加带有小气泡的海洋般的背景,而不是蓝色。我搜索了但没有找到解决方案。
我的布局是:
<LinearLayout android:id="@+id/switcher_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light">
<HorizontalScrollView android:id="@+id/switcher_scroller"
android:background="@color/blue_200"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout android:id="@+id/switcher_container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
目前看起来像:
我需要一些类似水的气泡和动画,而不是静态的蓝色!
为了使任务变得非常简单..首先像这样更改布局..
<FrameLayout android:id="@+id/switcher_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/vView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<HorizontalScrollView
android:id="@+id/switcher_scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout android:id="@+id/switcher_container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
然后制作动画视频..将 mp4 文件存储在资源的原始文件夹中..(编写动画并点击它会对 gpu 渲染有点苛刻)..
VideoView view = (VideoView)findViewById(R.id.vView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
您可以检测视频的完成,并可以使用以下代码重播它..
view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
view.start();
}
});
我在水平视图背景中添加了蓝色!但是我需要在布局中添加带有小气泡的海洋般的背景,而不是蓝色。我搜索了但没有找到解决方案。
我的布局是:
<LinearLayout android:id="@+id/switcher_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light">
<HorizontalScrollView android:id="@+id/switcher_scroller"
android:background="@color/blue_200"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout android:id="@+id/switcher_container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
目前看起来像:
我需要一些类似水的气泡和动画,而不是静态的蓝色!
为了使任务变得非常简单..首先像这样更改布局..
<FrameLayout android:id="@+id/switcher_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/vView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<HorizontalScrollView
android:id="@+id/switcher_scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout android:id="@+id/switcher_container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
然后制作动画视频..将 mp4 文件存储在资源的原始文件夹中..(编写动画并点击它会对 gpu 渲染有点苛刻)..
VideoView view = (VideoView)findViewById(R.id.vView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
您可以检测视频的完成,并可以使用以下代码重播它..
view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
view.start();
}
});