跳至主要内容

博文

目前显示的是 九月, 2016的博文

Android 在布局容器中动态添加控件

这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理。 1、addView 添加控件到布局容器 2、removeView 在布局容器中删掉已有的控件 TextView textView= new TextView (MainActivity. this ); views .add(textView); textView.setText( "hello world" ); relativeLayout .addView(textView,0);

Android Animation

button.getPivotX()*2  == button's  width button.getX()  ==  button's  absolute x float sx1 = button .getPivotX() , sy1= button .getScaleY() , sy2= textView .getScaleY() ; TranslateAnimation translateAnimation= new TranslateAnimation ( Animation. ABSOLUTE , 0f , Animation. ABSOLUTE , sx1 , Animation. ABSOLUTE , 0f , Animation. ABSOLUTE , sy1+sy2 ) ; translateAnimation.setFillAfter( true ) ; translateAnimation.setDuration( 1000 ) ; textView .startAnimation(translateAnimation) ; animation. setRepeatCount ( 10 ); animation. setRepeatMod  ( Animation. REVERSE ); 四、具体实现 2 、 .java 文件 Animation Set :             AnimationSet animationSet =   new   AnimationSet( true );             animationSet.addAnimation(alphaAnimation); AlphaAnimation :             AlphaAnimation alphaAnimation =   new   AlphaAnimation(1, 0); ScaleAnimation :