programming4us
programming4us
MOBILE

Beginning Android 3 : Working with Containers - Scrollwork

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
Phone screens tend to be small, which requires developers to use some tricks to present a lot of information in the limited available space. One trick for doing this is to use scrolling, so that only part of the information is visible at one time, and the rest is available via scrolling up or down.

ScrollView is a container that provides scrolling for its contents. You can take a layout that might be too big for some screens, wrap it in a ScrollView, and still use your existing layout logic. The user can see only part of your layout at one time, and see the rest via scrolling.

For example, here is a ScrollView used in an XML layout file (from the Containers/Scroll demo):

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"

android:layout_height="wrap_content">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow>
<View
android:layout_height="80dip"
android:background="#000000"/>
<TextView android:text="#000000"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#440000" />
<TextView android:text="#440000"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#884400" />
<TextView android:text="#884400"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#aa8844" />
<TextView android:text="#aa8844"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#ffaa88" />
<TextView android:text="#ffaa88"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#ffffaa" />
<TextView android:text="#ffffaa"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
<TableRow>
<View
android:layout_height="80dip"
android:background="#ffffff" />


<TextView android:text="#ffffff"
android:paddingLeft="4dip"
android:layout_gravity="center_vertical" />
</TableRow>
</TableLayout>
</ScrollView>

Without the ScrollView, the table would take up at least 560 pixels (seven rows at 80 pixels each, based on the View declarations). There may be some devices with screens capable of showing that much information, but many will be smaller. The ScrollView lets us keep the table as is, but present only part of it at a time.

On the stock Android emulator, when the activity is first viewed, it appears as shown in Figure 1.

Figure 1. The ScrollViewDemo sample application

Notice how only five rows and part of the sixth are visible. By pressing the up/down buttons on the D-pad, you can scroll up and down to see the remaining rows. Also note how the right side of the content is clipped by the scrollbar—be sure to put some padding on that side or otherwise ensure your own content does not get clipped in that fashion.

Android 1.5 introduced HorizontalScrollView, which works like ScrollView, but horizontally. This is useful for forms that might be too wide rather than too tall. Note that neither ScrollView nor HorizontalScrollView will give you bidirectional scrolling, so you have to choose vertical or horizontal.

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us