gpt4 book ai didi

android - View 的闪烁边框

转载 作者:行者123 更新时间:2023-11-29 01:15:57 27 4
gpt4 key购买 nike

我有一个 View 和一个边框,我想在特定时间闪烁。我试着眨眼,但问题是整个 View 都在闪烁。我知道这是因为我在 Linearlayout 中提到了 View,背景设置为边框。

代码如下:

xml:
<LinearLayout
android:layout_width="14dp"
android:layout_height="14dp
android:id="@+id/rect2"
android:background="@drawable/cir"
>

<View
android:layout_width="5dp"
android:layout_height="5dp"
android:background="#14FFFFFF"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:id="@+id/inrect2"
/>
</LinearLayout>

Java:

 //somecode
setContentView(R.layout.activity_main);
re2=(LinearLayout)findViewById(R.id.rect2);
myView2= findViewById(R.id.inrect2);

((GradientDrawable)re1.getBackground()).setStroke(1,Color.WHITE);
AlphaAnimation blinkanimation= new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
blinkanimation.setDuration(500); // duration - half a second
blinkanimation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
blinkanimation.setRepeatCount(28); // Repeat animation infinitely
blinkanimation.setRepeatMode(Animation.REVERSE);
re1.startAnimation(blinkanimation);

re1.startAnimation(blinkanimation) 似乎开始对整个线性布局进行动画处理,无论如何我可以让 blink only 边框?任何帮助,将不胜感激!谢谢!

最佳答案

不要闪烁 View ,而是尝试闪烁外部线性布局, View 和线性布局之间应该有填充,以便提供类似边框的效果。

[编辑]

尝试使用 FrameLayoutView 堆叠在 LinearLayout 之上,LinearLayout 应该稍微大一点模拟类似边框的效果。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Linearlayout
android:background="#00000000"
android:layout_gravity="center"
android:layout_width="20dp"
android:layout_height="20dp"
/>

<View
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center"
android:gravity="center"
android:background="#AA000000" />

</FrameLayout>

关于android - View 的闪烁边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39688248/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com