如何在点击屏幕时同时显示多个 ImageView?(在一个 ImageView 上画圈)。

huangapple go评论92阅读模式
英文:

How can I have more than one imageview on the screen at the same time when I click the screen? (Circle one imageview)

问题

在安卓上,无论我在哪里触摸,我都想显示ImageView。你能帮我吗?

在我下面写的文章中,我的项目是关于我想如何使用它。

你需要从用户获取屏幕触摸位置,每次在屏幕上点击时都应该在屏幕上创建一个新组件,你可以在Java侧实现这一点,每个生成的组件将在屏幕上显示并在1秒后消失,你可以使用计时器,也可以使用安卓的本地动画。换句话说,我们现在想要的是,每次在屏幕上点击时都创建一个新的圆,并且同时在屏幕上有多个圆,每个圆都有自己的起始时间和结束时间,在时间到达后这些组件将被移除。

英文:

Imageview wherever I touch on Android
I want to show. Can you help me?

In the article I wrote below, my project is how I want to use it.

You have to get screen pressure as we want from you, you should create a new component on the screen every time you click on the screen, you can do this on the java side, every component that is produced will appear and disappear on the screen for 1 second, you can use the timer, you can use the native animations of the android. In other words, what we want right now is to create a new circle with each click on the screen and to have more than one circle at the same time on the screen, and each will have its own start and end time, the components will be removed when the time is up.

答案1

得分: 0

使用状态可绘制对象(state drawable)在你的图像视图(image view)上。设置 drawable,其中 state_pressed="true" 和 state_pressed="false"。这将实现你所需的效果。

链接:https://stackoverflow.com/questions/14042866/state-list-drawable-and-disabled-state

英文:

Use state drawable on your image view. Set drawable what you want state_pressed="true" and state_pressed="false". This will do the magic what you want

https://stackoverflow.com/questions/14042866/state-list-drawable-and-disabled-state

答案2

得分: 0

使用选择器背景:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 按下状态 -->
    <item android:drawable="@drawable/button_1_selected" android:state_pressed="true"/>
    <!-- 聚焦状态 -->
    <item android:drawable="@drawable/button_1_normal" android:state_focused="true"/>
    <!-- 默认状态 -->
    <item android:drawable="@drawable/button_1_normal"/>
</selector>
英文:

use selector background:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
&lt;!-- pressed --&gt;
&lt;item android:drawable=&quot;@drawable/button_1_selected&quot; android:state_pressed=&quot;true&quot;/&gt;
&lt;!-- focused --&gt;
&lt;item android:drawable=&quot;@drawable/button_1_normal&quot; android:state_focused=&quot;true&quot;/&gt;
&lt;!-- default --&gt;
&lt;item android:drawable=&quot;@drawable/button_1_normal&quot;/&gt;

</selector>

huangapple
  • 本文由 发表于 2020年8月20日 00:14:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/63491064.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定