LogoLogo
v7.0.0
v7.0.0
  • TotalCross Overview
  • TotalCross Javadoc
  • TotalCross Changelog
  • Roadmap
  • Documentation
    • Getting Started
      • First embedded project with TotalCross
    • Components
      • Accordion
      • Aligned Labels
      • Button
      • Check
      • ComboBox
      • Dynamic Scroll
      • Edit
      • Floating Button
      • Gpiod
      • Grid
      • GridContainer
      • Image
      • ImageControl
      • ImageList
      • Label
      • Material Icons
      • Material Window
      • MessageBox
      • Multi Edit
      • Progress Bar
      • Progress Box
      • Radio
      • Radio Group
      • Scroll Container
      • Side Menu
      • Slider
      • Sliding Window
      • Spin List
      • Spinner
      • Switch
      • Tabbed Container
      • Velocimeter
    • APIs
      • API Overview
      • API Rest
      • Asynchronous Task
      • Camera
      • Control
        • Main Window
        • Window
        • Container
      • GPS
      • HTTPS and SSL
      • JSON
      • Maps
        • Maps - Deprecated
        • Static Map
      • Material Design Standards
      • Ninepath
      • Notifications
      • PrinterManager
      • Push Notification Firebase
      • Scanner
      • SOAP
      • Socket
      • SocketServer
      • SQLite Encryption
      • QR Code Generator
      • totalcross.sys
      • Youtube API
    • Creating an Issue
    • Contributing
      • Branch workflow
      • Writing documentation
    • Guides
      • App Architecture
        • Suggested Architecture
        • Why do Design Patterns help with the application's organization?
          • MVC Architecture Pattern
          • Template Pattern
          • Data Persistence: DAO Pattern.
        • Separation of concepts: What is the best way to create UI interfaces?
        • Positioning
          • Manual Positioning
        • Relative Positioning
        • Best practices to improve project maintenance
      • Device Simulator
      • Package your app from scratch
        • TotalCross SDK
        • Environment Variables in IDE
          • Eclipse
          • IntelliJ
        • Deploy your app with a dependecy TC
        • Deploy iOS
          • Using Development certificate to test your apps
      • Understanding TotalCross for Linux ARM
      • Running C++ applications with TotalCross
      • Web Services
    • Miscelaneous
      • Java JDK 8
      • Maven
      • Installing Visual Studio Code
    • FAQ
      • IMEI in Android 10
Powered by GitBook
On this page
  • Overview
  • How to use
  • References

Was this helpful?

  1. Documentation
  2. Components

Scroll Container

Overview

The Container scroll is a container that has side scroll, horizontal scroll or no scroll.

How to use

public class ScrollContainerSample extends MainWindow {

    public ScrollContainerSample(){
        setUIStyle(Settings.Material);
    }

    @Override
        public void initUI() {
            super.initUI();
            ScrollContainer sc = new ScrollContainer(false, true);
            int gap = UnitsConverter.toPixels(DP + 16);
            sc.setInsets(gap, gap, gap, gap);
            add(sc, LEFT, TOP, FILL, FILL);

            Button b;
            ScrollContainer sc1, sc2, sc3;
            // a ScrollContainer with both ScrollBars
            sc.add(new Label("Vertical and horizontal:"), LEFT, TOP);
            sc.add(sc1 = new ScrollContainer());
            sc1.setBorderStyle(BORDER_ROUNDED);
            sc1.setInsets(3, 3, 3, 3);
            sc1.setRect(LEFT, AFTER, FILL, SCREENSIZE + 30);
            int xx = new Label("Name99").getPreferredWidth() + 2; // edit's alignment
            for (int i = 0; i < 50; i++) {
                sc1.add(new Label("Name" + i), LEFT, AFTER + 10);
                sc1.add(new Edit(), xx, SAME, SCREENSIZE + 90, PREFERRED);
                if (i % 3 == 0) {
                    sc1.add(new Button("Go"), AFTER + 2, SAME, PREFERRED, SAME);
                }
            }

            // a ScrollContainer with vertical ScrollBar disabled
            sc.add(new Label("Horizontal-only:"), LEFT, AFTER + gap);
            sc.add(sc2 = new ScrollContainer(true, false));
            sc2.setBorderStyle(BORDER_ROUNDED);
            sc2.setInsets(3, 3, 3, 3);
            int lines = Settings.screenHeight > 320 ? 4 : 3;
            sc2.setRect(LEFT, AFTER, FILL, lines * (fmH + Edit.prefH) + fmH / 2);
            for (int i = 0; i < lines; i++) {
                sc2.add(new Label("Name" + i), LEFT, AFTER);
                sc2.add(new Edit(""), xx, SAME, PARENTSIZE + 200, PREFERRED); // fit
                sc2.add(new Button("Go"), AFTER, SAME, PREFERRED, SAME);
            }

            // a ScrollContainer with horizontal ScrollBar disabled
            sc.add(new Label("Vertical-only:"), LEFT, AFTER + gap);
            sc.add(sc3 = new ScrollContainer(false, true));
            sc3.setBorderStyle(BORDER_ROUNDED);
            sc3.setInsets(3, 3, 3, 3);
            sc3.setRect(LEFT, AFTER, FILL, SCREENSIZE + 30);
            for (int i = 0; i < 50; i++) {
                sc3.add(new Label("Name" + i), LEFT, AFTER);
                sc3.add(b = new Button("Go"), RIGHT, SAME, PREFERRED, SAME);
                sc3.add(new Edit(""), xx, SAME, FIT - 2, PREFERRED, b); // fit
            }
        }
}

References

PreviousRadio GroupNextSide Menu

Last updated 5 years ago

Was this helpful?

To know more details read its .

JavaDocs