HorizontalScrollView左右滚动的动画

来源:互联网 发布:阿里云tv cvtm628_512 编辑:程序博客网 时间:2024/04/29 08:15
1、layout 文件 main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >     <HorizontalScrollView android:id="@+id/list"     android:layout_width="fill_parent"     android:layout_height="wrap_content" >         <LinearLayout android:id="@+id/list_layout"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:orientation="horizontal" >         </LinearLayout>     </HorizontalScrollView> </LinearLayout>
2、activity
public class MainActivity extends Activity {    private LinearLayout list_layout;    private TranslateAnimation animation;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        list_layout=(LinearLayout)findViewById(R.id.list_layout);        animation=new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_PARENT, -1.0f,   Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);        animation.setDuration(1000);        list_layout.startAnimation(animation);    }}


原创粉丝点击