package com.study.beta;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private TextView tv1;
private Button bt1;
private Button bt2;
private ScrollView scrollView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scrollView= (ScrollView) findViewById(R.id.scroll);
tv1= (TextView) findViewById(R.id.content);
tv1.setText(getResources().getString(R.string.beta));
bt1= (Button) findViewById(R.id.bt1);
bt2= (Button) findViewById(R.id.bt2);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_MOVE:{
if (scrollView.getScrollY()<+0){
Log.i("高度","微电机");
}
if (scrollView.getChildAt(0).getMeasuredHeight()==scrollView.getHeight()+scrollView.getScrollY()){
Log.i("高度","华东到底部");
tv1.append(getResources().getString(R.string.beta));
}
}
}
return false;
}
});
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.bt1:scrollView.scrollBy(0,-2);
}
}
}