如何在java中将imageview添加到具有延迟的图层

时间:2017-03-16 17:59:32

标签: java android eclipse android-studio

线程和睡眠以及处理程序都没有帮助。 这是我的代码。

a:not(.btn) {
    text-decoration: none;
    border-bottom: 3px solid #b4e7f8;
    box-shadow: inset 0 -4px 0 #b4e7f8;
    -webkit-transition: background .35s cubic-bezier(.33,.66,.66,1);
    transition: background .35s cubic-bezier(.33,.66,.66,1);
    color: inherit;
}
a:not(.btn):hover{
    background: #b4e7f8;
    text-decoration: none;
}
 a:not(.btn):visited {
    border-bottom: 3px solid #beb4f8;
  background: #beb4f8;
  -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    color: inherit;
}

2 个答案:

答案 0 :(得分:0)

试试这个

T

答案 1 :(得分:0)

这应该有效:

while(true){
        ImageView image = new ImageView(context);
        image.setLayoutParams(new android.view.ViewGroup.LayoutParams(80,60));
        image.setMaxHeight(80);
        image.setMaxWidth(50);
        image.setImageResource(R.drawable.missile);


        TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 10.0f, -800.0f);          //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
        animation.setDuration(700);   
        animation.setFillAfter(true); 
        image.startAnimation(animation);
        LinearLayout missile_layout = (LinearLayout)findViewById(R.id.missile_layout);

    missile_layout.postDelayed(new Runnable() {
        public void run() {
            missile_layout.addView(image,0);
        }
    }, 5000
);
}