闪烁视图的边界

时间:2016-09-25 14:54:49

标签: android

我有一个 <dependency> <groupId>org.igniterealtime.smack</groupId> <artifactId>smack-core</artifactId> <version>4.0.6</version> </dependency> <dependency> <groupId>org.igniterealtime.smack</groupId> <artifactId>smack-tcp</artifactId> <version>4.0.6</version> </dependency> 和一个我希望在特定时间闪烁的边框。我试图眨眼但问题是整个视图都在眨眼。我知道它的来源我在View里面提到View哪个背景设置为边境存量。

以下是代码:

Linearlayout

的java:

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>

//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); 似乎开始动画整个线性布局,无论如何,我只能闪烁边界吗? 任何帮助,将不胜感激!谢谢!

1 个答案:

答案 0 :(得分:1)

不要闪烁视图,尝试闪烁外部线性布局,视图和线性布局应该在它们之间有填充,以便给出类似边框效果。

<强> [编辑]

尝试使用ViewLinearLayout上叠加FrameLayoutLinearLayout应略大,以模拟边框效果。

<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>