GIF图片在点击按钮时再次不可见。它是第一次使用,但不适用于按钮单击事件;
我使用以下代码在imageview中加载GIF;
<form action="#" onsubmit="data(name, age, email, dob)">
<!--data(name, age, email, dob)-->
<!--onsubmit="return validate()"-->
<div class="form-group">
<label class="form-text">Name :</label>
<input type="text" id="Name" placeholder="Enter Name" class="form-control" " />
<span id="ErrorName " class="text-danger "></span>
</div>
<div class="form-group ">
<label class="form-text ">Age :</label>
<input type="text " id="Age " placeholder="Enter Age " class="form-control " />
<span id="ErrorAge " class="text-danger "></span>
</div>
<div class="form-group ">
<label class="form-text ">Email :</label>
<input type="text " id="Email " placeholder="Enter Email " class="form-control " />
<span id="ErrorEmail " class="text-danger " />
</div>
<div class="form-group ">
<label class="form-text ">Password :</label>
<input type="password " id="Password " placeholder="Enter Password " class="form-control " />
<span id="ErrorPassword " class="text-danger "></span>
</div>
<div class="form-group ">
<label class="form-text ">Confirm Password :</label>
<input type="password " id="ConfirmPassword " placeholder="Confirm Password " class="form-control " onblur=" " />
<span id="ErrorConfirmPassword " class="text-danger "></span>
</div>
<div class="form-group ">
<label class="form-text ">Date of Birth :</label>
<input type="date " id="DOB " class="form-control " />
<span id="ErrorDOB " class="text-danger "></span>
</div>
<div class="form-group col-lg-12 text-center ">
<input type="submit " id="Submit " class="btn btn-success " />
</div>
</form>
<div class="container " id="user ">
</div>
<br />
<div class="form-group " id="edit ">
</div>
下面是GIF消失的代码;
Glide.with(getApplicationContext()).load(R.drawable.loading_progress).asGif().into(ImgV);
再次使用以下代码在按钮点击事件中看不到GIF;
ImgV.setVisibility(View.GONE);
答案 0 :(得分:1)
第一个决定 使用
重新加载gifGlide.with(getApplicationContext()).load(R.drawable.loading_progress).asGif().into(ImgV);
更改可见性后
ImgV.setVisibility(View.VISIBLE);
第二个决定 只需致电
ImgV.invalidate()
答案 1 :(得分:0)
您可以使用此库来显示和隐藏按钮上的GIF点击SingleOrDefault
在构建包中添加以下内容:
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
}
在您的Xml文件中:
<pl.droidsonroids.gif.GifImageView
android:id="@+id/gif"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/tenor"
/>
然后在您的Java文件中
GifImageView gifImageView = findViewById(R.id.gif);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (gifImageView.getVisibility() == View.VISIBLE) {
gifImageView.setVisibility(View.GONE);
} else {
gifImageView.setVisibility(View.VISIBLE);
}
}
});