List of usage examples for android.widget HorizontalScrollView addView
@Override public void addView(View child, ViewGroup.LayoutParams params)
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeFontBox() { int boxColor = Color.rgb(241, 238, 229); int innerBoxColor = Color.rgb(246, 244, 239); int inlineColor = Color.rgb(133, 105, 75); int width = 450; int height = 500; fontBox = new SkyBox(this); fontBox.setBoxColor(boxColor);//from w w w . j av a 2s . c o m fontBox.setArrowHeight(ps(25)); fontBox.setArrowDirection(false); setFrame(fontBox, ps(50), ps(200), ps(width), ps(height)); ScrollView fontBoxScrollView = new ScrollView(this); this.setFrame(fontBoxScrollView, ps(5), ps(10), ps(440), ps(height - 50)); fontBox.contentView.addView(fontBoxScrollView); // NEW SkyLayout contentLayout = new SkyLayout(this); fontBoxScrollView.addView(contentLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // #1 first make brightness controller // brView is the box containing the bright slider. int FY = 10; View brView = new View(this); RoundRectShape rrs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable srd = new SkyDrawable(rrs, innerBoxColor, inlineColor, 1); brView.setBackgroundDrawable(srd); setFrame(brView, ps(20), ps(FY), ps(width - 40), ps(53)); contentLayout.addView(brView); // darker and brighter icons int SBS = 60; ImageButton sbb = this.makeImageButton(9005, R.drawable.brightness2x, ps(SBS), ps(SBS)); setFrame(sbb, ps(50), ps(FY), ps(SBS), ps(SBS)); sbb.setAlpha(200); int BBS = 70; ImageButton bbb = this.makeImageButton(9006, R.drawable.brightness2x, ps(BBS), ps(BBS)); setFrame(bbb, ps(width - 110), ps(FY - 5), ps(BBS), ps(BBS)); bbb.setAlpha(200); contentLayout.addView(sbb); contentLayout.addView(bbb); // making bright slider brightBar = new SeekBar(this); brightBar.setMax(999); brightBar.setId(997); brightBar.setBackgroundColor(Color.TRANSPARENT); brightBar.setOnSeekBarChangeListener(new SeekBarDelegate()); brightBar.setProgressDrawable(new LineDrawable(Color.rgb(160, 160, 160), ps(10))); brightBar.setThumbOffset(-1); setFrame(brightBar, ps(100), ps(FY + 4), ps(width - 210), ps(50)); contentLayout.addView(brightBar); // #2 second make decrese/increse font size buttons // decrease font size Button int FBY = 80; decreaseButton = new Button(this); setFrame(decreaseButton, ps(20), ps(FBY), ps(width - 40 - 20) / 2, ps(60)); decreaseButton.setText(getString(R.string.chara)); decreaseButton.setGravity(Gravity.CENTER); decreaseButton.setTextSize(14); decreaseButton.setId(5000); RoundRectShape drs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable drd = new SkyDrawable(drs, innerBoxColor, inlineColor, 1); decreaseButton.setBackgroundDrawable(drd); decreaseButton.setOnClickListener(listener); decreaseButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(decreaseButton)); contentLayout.addView(decreaseButton); // inccrease font size Button increaseButton = new Button(this); setFrame(increaseButton, ps(10 + width / 2), ps(FBY), ps(width - 40 - 20) / 2, ps(60)); increaseButton.setText(getString(R.string.chara)); increaseButton.setTextSize(18); increaseButton.setGravity(Gravity.CENTER); increaseButton.setId(5001); RoundRectShape irs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable ird = new SkyDrawable(irs, innerBoxColor, inlineColor, 1); increaseButton.setBackgroundDrawable(ird); increaseButton.setOnClickListener(listener); increaseButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(increaseButton)); contentLayout.addView(increaseButton); // # 3 make the button to increase/decrese line spacing. int LBY = 145; // deccrease line space Button decreaseLineSpaceButton = this.makeImageButton(9005, R.drawable.decline2x, ps(30), ps(30)); setFrame(decreaseLineSpaceButton, ps(20), ps(LBY), ps(width - 40 - 20) / 2, ps(60)); decreaseLineSpaceButton.setId(4000); drs = new RoundRectShape(new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); drd = new SkyDrawable(drs, innerBoxColor, inlineColor, 1); decreaseLineSpaceButton.setBackgroundDrawable(drd); decreaseLineSpaceButton.setOnClickListener(listener); decreaseLineSpaceButton .setOnTouchListener(new ImageButtonHighlighterOnTouchListener(decreaseLineSpaceButton)); contentLayout.addView(decreaseLineSpaceButton); // inccrease line space Button increaseLineSpaceButton = this.makeImageButton(9005, R.drawable.incline2x, ps(30), ps(30)); setFrame(increaseLineSpaceButton, ps(10 + width / 2), ps(LBY), ps(width - 40 - 20) / 2, ps(60)); increaseLineSpaceButton.setId(4001); irs = new RoundRectShape(new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); ird = new SkyDrawable(irs, innerBoxColor, inlineColor, 1); increaseLineSpaceButton.setBackgroundDrawable(ird); increaseLineSpaceButton.setOnClickListener(listener); increaseLineSpaceButton .setOnTouchListener(new ImageButtonHighlighterOnTouchListener(increaseLineSpaceButton)); contentLayout.addView(increaseLineSpaceButton); // #4 make themes selector. int TY = 220; int TH = 70; int TW = (width - 40 - 20) / 3; HorizontalScrollView themeScrollView = new HorizontalScrollView(this); themesView = new LinearLayout(this); themesView.setOrientation(LinearLayout.HORIZONTAL); themeScrollView.addView(themesView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); for (int i = 0; i < this.themes.size(); i++) { Theme theme = themes.get(i); Button themeButton = new Button(this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ps(TW), ps(TH)); layoutParams.setMargins(0, 0, 24, 0); themesView.addView(themeButton, layoutParams); RoundRectShape rs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable brd = new SkyDrawable(rs, theme.backgroundColor, Color.BLACK, 1); themeButton.setBackgroundDrawable(brd); themeButton.setText(theme.name); themeButton.setTextColor(theme.foregroundColor); themeButton.setId(7000 + i); themeButton.setOnClickListener(listener); } this.setFrame(themeScrollView, ps(20), ps(TY), ps(width - 40), ps(90)); contentLayout.addView(themeScrollView); // #5 font list box int SY = 310; int fontButtonHeight = 80; int fontListHeight; fontListHeight = fontButtonHeight * fonts.size(); fontListView = new LinearLayout(this); fontListView.setOrientation(LinearLayout.VERTICAL); contentLayout.addView(fontListView); this.setFrame(fontListView, ps(20), ps(SY), ps(width - 40), ps(fontListHeight)); int inlineColor2 = Color.argb(140, 133, 105, 75); for (int i = 0; i < fonts.size(); i++) { CustomFont customFont = fonts.get(i); Button fontButton = new Button(this); fontButton.setText(customFont.fontFaceName); fontButton.setTextSize(20); Typeface tf = null; if (customFont.fontFileName == null || customFont.fontFileName.isEmpty()) { tf = this.getTypeface(customFont.fontFaceName, Typeface.BOLD); } else { tf = Typeface.createFromAsset(getAssets(), "fonts/" + customFont.fontFileName); } if (tf != null) fontButton.setTypeface(tf); fontButton.setId(5100 + i); RoundRectShape rs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable brd = new SkyDrawable(rs, innerBoxColor, inlineColor2, 1); fontButton.setBackgroundDrawable(brd); this.setFrame(fontButton, ps(0), ps(0), ps(width - 40), ps(fontButtonHeight)); fontListView.addView(fontButton); fontButton.setOnClickListener(listener); fontButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(fontButton)); } this.ePubView.addView(fontBox); this.hideFontBox(); }