Skip to content

Instantly share code, notes, and snippets.

@Lanace
Created July 19, 2017 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lanace/5d80b18c331d7cdc746092063af78ee1 to your computer and use it in GitHub Desktop.
Save Lanace/5d80b18c331d7cdc746092063af78ee1 to your computer and use it in GitHub Desktop.
스크롤뷰에서 버튼을 클릭했을 때 스크롤의 최 상단으로 이동시키는 코드
public class MainActivity extends AppCompatActivity {
Button button;
ScrollView scrollView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scrollView = (ScrollView) findViewById(R.id.scrollView);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
scrollView.fullScroll(ScrollView.FOCUS_UP);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment