메뉴 건너뛰기

2015.07.16 19:35

ScrollView의 활용

조회 수 6537 추천 수 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.}

  1. 스토리보드 짜는 방법

    Date2015.07.16 Views15432
    Read More
  2. 탭 뷰에 탭 추가하기, 아이콘 넣기

    Date2015.07.16 Views9365
    Read More
  3. 푸쉬 알림 기능. GCM (Google Cloud Messaging) 사용하기 (3)

    Date2015.07.16 Views6271
    Read More
  4. 푸쉬 알림 기능. GCM (Google Cloud Messaging) 사용하기 (2)

    Date2015.07.16 Views7297
    Read More
  5. 푸쉬 알림 기능. GCM (Google Cloud Messaging) 사용하기 (1)

    Date2015.07.16 Views6730
    Read More
  6. 네트워크 상태 변화 감지하기(BroadcastReceiver 사용)

    Date2015.07.16 Views9947
    Read More
  7. 옵션 메뉴 동적으로 생성하기

    Date2015.07.16 Views6933
    Read More
  8. EditText의 글자 수 제한 걸기

    Date2015.07.16 Views13884
    Read More
  9. 사용자 정의 팝업창 띄우기

    Date2015.07.16 Views6343
    Read More
  10. 체크 박스(CheckBox)의 이미지 바꾸기

    Date2015.07.16 Views6419
    Read More
  11. 이미지 버튼(ImageButton) 만들기

    Date2015.07.16 Views7116
    Read More
  12. 이미지의 Orientation를 체크해서 이미지 회전하기

    Date2015.07.16 Views7668
    Read More
  13. 화면 회전에 따른 애니메이션 효과 구현하기

    Date2015.07.16 Views8066
    Read More
  14. 화면 해상도에 관계없는 레이아웃(Layout) 만들기

    Date2015.07.16 Views8651
    Read More
  15. 네트워크를 통해 받은 이미지를 파일로 저장하고, 크기 조절해서 불러오기

    Date2015.07.16 Views6160
    Read More
  16. 특정 폴더에서 오래된 파일 삭제하기

    Date2015.07.16 Views6780
    Read More
  17. ScrollView의 활용

    Date2015.07.16 Views6537
    Read More
  18. ViewFlipper 사용하기

    Date2015.07.16 Views9635
    Read More
  19. URL을 이용해서 이미지 다운로드 하기 (멀티 쓰레드 이용)

    Date2015.07.16 Views8995
    Read More
  20. URL을 이용해서 이미지 다운로드 하기

    Date2015.07.16 Views7418
    Read More
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 Next
/ 13

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved