Created
July 19, 2017 02:59
-
-
Save Lanace/5d80b18c331d7cdc746092063af78ee1 to your computer and use it in GitHub Desktop.
스크롤뷰에서 버튼을 클릭했을 때 스크롤의 최 상단으로 이동시키는 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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