【发布时间】:2016-11-20 13:06:09
【问题描述】:
我一般需要什么:通过单击按钮将一个视图替换(隐藏)另一个视图
让我们深入了解一下: 我使用 ViewPager,它包含 100 张图片。
ViewPager的布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#ffffff" >
</android.support.v4.view.ViewPager>
<ImageButton
android:id="@+id/imagePlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageRight"
android:layout_alignTop="@+id/imageList"
android:src="@drawable/list" />
</RelativeLayout>
图片布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dip"
android:background="#ffffff">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
它有效 - 没问题。但是我需要在viewpager中添加按钮,并且在viewpager中点击图像后应该将其更改为gif。它看起来像 gif 预览和 onclick 播放后 - gif 开始播放。
GIF 的自定义布局:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageList"
android:layout_marginRight="28dp"
android:layout_toLeftOf="@+id/imageRight" >
<com.basv.gifmoviewview.widget.GifMovieView
android:id="@+id/gif1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
应该如何解决?在点击按钮后打开另一个活动对我来说非常简单,但问题是在同一个片段中播放 gif
有什么想法吗?
【问题讨论】:
标签: android android-layout android-fragments android-imageview animated-gif