메뉴 건너뛰기

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.26 Views6397
    Read More
  2. 체크 박스(CheckBox)의 이미지 바꾸기

    Date2015.07.16 Views6420
    Read More
  3. jQuery Ajax - jQuery.load() 메서드 (동적으로 원격 페이지 로드)

    Date2014.10.16 Views6427
    Read More
  4. HTML5 Speech Input (음성인식) API

    Date2014.09.04 Views6455
    Read More
  5. HTML5로 나만의 비디오 플레이어 스킨 만들기 -1- CSS

    Date2014.09.04 Views6458
    Read More
  6. 맵에 오버레이 추가하여 아이템 넣어보기

    Date2014.08.28 Views6481
    Read More
  7. Android] Fragment 내부의adapter에서 startActivity 하기

    Date2015.12.15 Views6501
    Read More
  8. ScrollView의 활용

    Date2015.07.16 Views6537
    Read More
  9. 폰갭 비콘 디텍팅 안될 때 (기본적인건 다 되있어야됨)

    Date2015.07.26 Views6537
    Read More
  10. 서비스가 실행중인지 알아보는 방법

    Date2015.07.16 Views6559
    Read More
  11. JSON(JavaScript Object Notation) - jQuery Ajax - jQuery.getJSON() 메서드 (비동기적으로 JSON파일 로드)

    Date2014.10.16 Views6570
    Read More
  12. JavaScript 맛보기

    Date2014.09.04 Views6592
    Read More
  13. 실행중인 Service 확인하기

    Date2014.08.28 Views6598
    Read More
  14. 버튼 누르면 이미지 바꾸기

    Date2015.07.26 Views6622
    Read More
  15. Android TIP] strings.xml 에서 특수문자 사용하기

    Date2015.12.15 Views6634
    Read More
  16. 안드로이트 비콘 스캐닝시 고려 사항

    Date2015.07.26 Views6665
    Read More
  17. 안드로이드 스튜디오 gradle error 해결

    Date2015.07.23 Views6689
    Read More
  18. jQuery ajax post 요청 text 응답

    Date2014.10.16 Views6710
    Read More
  19. 트리뷰(TreeView) 컨트롤

    Date2014.10.16 Views6727
    Read More
  20. 푸쉬 알림 기능. GCM (Google Cloud Messaging) 사용하기 (1)

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

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved