Search

'scrollview'에 해당되는 글 1건

  1. 2010.12.25 android - scrollview

android - scrollview

Programming/안드로이드 2010.12.25 18:16 Posted by 파란크리스마스

출처 : http://tigerwoods.tistory.com/12
http://vulpecula.tistory.com/3
http://nashorn.tistory.com/74
http://blog.vizpei.kr/94697746
http://www.jopenbusiness.com/tc/oss/entry/Android-ScrollView%EB%A1%9C-%ED%99%94%EB%A9%B4-%EC%8A%A4%ED%81%AC%EB%A1%A4-%EC%B2%98%EB%A6%AC
http://songdroid.blogspot.com/2009/12/linearlayout.html



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"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>
ScrollViewTest.java

package com.shryu.test;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class ScrollViewTest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        LayoutInflater inflate = LayoutInflater.from(this);
        LinearLayout layout = (LinearLayout)inflate.inflate(R.layout.main, null);
        this.setContentView(layout);
        
        //
        ScrollView sv = new ScrollView(this);
        sv.setLayoutParams(new RelativeLayout.LayoutParams(
             LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        layout.addView(sv);
        
        LinearLayout subLayout = new LinearLayout(this);
        subLayout.setLayoutParams(new LinearLayout.LayoutParams(
        		LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f));
        subLayout.setOrientation(LinearLayout.VERTICAL);
        subLayout.setPadding(0, 0, 5, 0);
        sv.addView(subLayout);
        
        for (int i=0; i<20; i++) {
          TextView aa = new TextView(this);
          aa.setBackgroundColor(Color.BLUE);
          aa.setText("blue - " + i);
          subLayout.addView(aa);
         
          TextView aa2 = new TextView(this);
          aa2.setBackgroundColor(Color.BLACK);
          aa2.setText("black - " + i);
          subLayout.addView(aa2);
        }
    }
}

 
신고


 

티스토리 툴바