android scrollby

   

        

代码

package com.example.ss;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
Button btn2,btn1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn1 = (Button) findViewById(R.id.button1);
        btn2 = (Button) findViewById(R.id.button2);
        btn2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//btn1.layout(100, 100, 300, 300);
				//容器左上为0,0
				// L 控件左边离容器左边的距离
				// T 控件顶部离容器顶部的距离
				// R 控件右边离容器左边的距离
				// B 控件底部离容器顶部的距离
				btn1.scrollBy(0,20);
			}
		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}


你可能感兴趣的:(android scrollby)