메뉴 건너뛰기

2015.07.16 19:35

ScrollView의 활용

조회 수 6530 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

TextView를 사용하다보면 내용이 너무 길어지는데, 이 때 스크롤을 하고 싶을 때가 있습니다.
이럴때 ScrollView를 사용하면 간단하게 해결이 됩니다.

너무 간단해서 layout의 xml 부분만 있으면 될 것 같습니다. 테스트로 사용한 main.xml 입니다.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    >

<ScrollView

    android:layout_width="fill_parent" 

   android:layout_height="100dip"> 

<TextView

android:id="@+id/textView"

android:layout_width="fill_parent" 

   android:layout_height="fill_parent" 

   android:text="@string/hello"

   />

    </ScrollView>

    

</LinearLayout> 


테스트를 위해 Activity에 다음과 같은 코드를 넣었습니다.

01.package Scroll.View.Example;
02. 
03.import android.app.Activity;
04.import android.os.Bundle;
05.import android.widget.TextView;
06. 
07.public class ScrollViewExample extends Activity {
08.    /** Called when the activity is first created. */
09.    @Override
10.    public void onCreate(Bundle savedInstanceState) {
11.        super.onCreate(savedInstanceState);
12.        setContentView(R.layout.main);
13.         
14.        String strText = "";
15.        for (int i=0; i<100; i++)
16.        {
17.            strText = strText + "텍스트 라인 : " + i + "\n";
18.        }
19.         
20.        TextView tv = (TextView)findViewById(R.id.textView);
21.         
22.        tv.setText(strText);
23.    }
24.}

List of Articles
번호 제목 날짜 조회 수
197 안드로이드 스튜디오 - getter/setter 메소드 자동생성 file 2021.03.29 583
196 안드로이드 스튜디오 actionbar(액션바) 사라짐 file 2020.12.14 614
195 [Android] 퍼미션 권한체크(테드퍼미션) 2021.09.14 616
194 안드로이드 스튜디오 - 싱글톤 패턴 (SingleTon Pattenr) 클래스 자동 생성 file 2021.03.29 621
193 안드로이드 - 갤러리에서 이미지 가져오기 2021.04.02 666
192 안드로이드 - AlertDialog 사용하여 알림창 띄우는 방법 총정리 file 2021.03.31 690
191 안드로이드 - 리사이클러뷰 (RecyclerView) notifyDataSetChanged 실행 시 깜빡 거리는 현상 2021.04.02 748
190 안드로이드에서 url 주소로 이미지 바로 불러오기 (Glide 사용) 2020.12.14 759
189 Firebase - 푸시알림 보내기 (2) 2021.09.30 768
188 안드로이드 - 문자열 배열 리소스 추가하기 <string-array> file 2021.03.31 811
187 안드로이드 - RatingBar를 통해 별점주기 file 2021.04.02 850
186 안드로이드 - Json 파싱하기 file 2021.04.02 851
185 ListView 리스트뷰 연습3 - 커스텀 리스트뷰 (Custom ListView) file 2020.12.14 906
184 안드로이드 - 문자열 리소스(Resource) 추가 및 참조하기 file 2021.03.31 906
183 안드로이드 - RecyclerView의 ViewType 구분하기 file 2021.04.02 934
182 안드로이드 - 플로팅 액션 버튼(Floating Action Button) 사용법 file 2021.04.02 971
181 하이브리드앱 기본 - WebView로 웹페이지 띄우기 file 2020.12.14 1025
180 WebView 작업할때 Net::ERR_UNKNOWN_URL_SCHEME 에러 발생할때 (전화걸기,문자보내기 안된다) 2020.12.14 1069
179 안드로이드 - KeyEvent(키 이벤트) 처리 file 2021.04.02 1214
178 안드로이드 - 텍스트뷰(TextView) 사용법 정리 file 2021.03.31 1254
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved