메뉴 건너뛰기

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.}

  1. MediaPlayer 클래스 사용법

    Date2018.10.02 Views1803
    Read More
  2. prepend(),append(),before(),after() 메서드

    Date2014.10.20 Views7361
    Read More
  3. ScrollView의 활용

    Date2015.07.16 Views6530
    Read More
  4. setContentView()와 레이아웃 전개자(LayoutInflater)

    Date2021.03.31 Views266
    Read More
  5. TextureView를 이용한 카메라 Preview 좌우 반전

    Date2015.06.10 Views14236
    Read More
  6. This Handler class should be static or leaks might occur 시 해결법

    Date2020.12.14 Views240
    Read More
  7. URL을 이용해서 이미지 다운로드 하기

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

    Date2015.07.16 Views8992
    Read More
  9. ViewFlipper 사용하기

    Date2015.07.16 Views9631
    Read More
  10. Virtual Device , 디자인 화면

    Date2021.03.31 Views260
    Read More
  11. Volley 로 웹요청하고 응답받기1 - Get방식

    Date2020.12.14 Views348
    Read More
  12. Volley 로 웹요청하고 응답받기2 - Post방식 , 로그인-회원가입 (php,mysql 연동)

    Date2020.12.14 Views1435
    Read More
  13. Volley 로 웹요청하고 응답받기3 - Get방식 , json 읽기 (php,mysql)

    Date2020.12.14 Views382
    Read More
  14. Volley 이용시에 한글 깨질때 UTF-8로 변경

    Date2020.12.14 Views350
    Read More
  15. WebView 작업할때 Net::ERR_UNKNOWN_URL_SCHEME 에러 발생할때 (전화걸기,문자보내기 안된다)

    Date2020.12.14 Views1071
    Read More
  16. WebView 줌 컨트롤러 가리기

    Date2014.08.28 Views6316
    Read More
  17. WebView를 사용할때 HttpClient를 이용한 Session 유지

    Date2018.12.27 Views4382
    Read More
  18. WebView에서 카메라 및 이미지 업로드 (선택적용가능)

    Date2020.12.14 Views2708
    Read More
  19. WIFI 신호세기 강도 측정하기

    Date2014.08.28 Views11243
    Read More
  20. XmlPullParser 를이용하여 데이터 가져와보기!!

    Date2014.08.28 Views7221
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved