我的约束布局有多个 View 。编辑文本和按钮。 我想使用运动背景。就像到处移动的物体。我已经为相同的内容制作了一个 GIF。但是如何将它应用到整个背景?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TypeSelection">
如何在其中放置 GIF?我想在这里声明它是将它应用于整个背景的最佳选择。
如果有任何其他方式.. 请帮助我。 如果您无法回答我的问题,请告诉我。
最佳答案
正如 Hadi Ahmadi 所提到的,您需要使用第 3 方库:pl.droidsonroids.gif.GifImageView
但他的回答不会将 GIF 作为背景,它只会像标题一样
开始制作新布局 my_GIF_Layout
并在其中放入您想要的 GIF
将 my_GIF_Layout 作为您的 rootLayout 放在 RelativeLayout 中,一切都会正常工作:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background="@color/app_bg"
android:gravity="center_horizontal">
<include layout="@layout/my_GIF_Layout"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
...Your layout code ...
</RelativeLayout >
</RelativeLayout >
关于android - 如何在后台应用 GIF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57937377/