1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | package com.test; import android.app.Activity; import android.os.Bundle; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; public class VerticalScrollViewActivity extends Activity { ImageView i; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout l = new LinearLayout(this); l.setOrientation(LinearLayout.VERTICAL); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); i = new ImageView(this); i.setImageResource(R.drawable.android); i.setPadding(5, 5, 0, 0); l.addView(i,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); ScrollView m_Scroll = new ScrollView(this); m_Scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); m_Scroll.addView(l, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) ); m_Scroll.setOverScrollMode(1); m_Scroll.setSmoothScrollingEnabled(true); //addContentView(m_Scroll, new LayoutParams(LayoutParams.FILL_PARENT, //LayoutParams.WRAP_CONTENT)); setContentView(m_Scroll); } } |
Sunday, September 2, 2012
Simple Vertical ScrollView (android)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment