Androidlayoutrow1

This preview shows page 47 - 54 out of 78 pages.

android:layout_column="1" android:layout_columnSpan="2" android:layout_row="1" android:layout_rowSpan="2" android:background="#ff7700" android:gravity="center" android:text="two" /> Here is an example of an XML layout resource with a GridLayout view resulting in four rows and four columns. Each child control occupies a certain number of rows and columns. Because the default span attribute value is 1, we specify only when the element will take up more than one row or column. For instance, the first TextView is one row high and three columns wide. The height and width of each of the View controls are specified to control the look of the result; otherwise, the GridLayout control will automatically assign sizing.
Image of page 47

Subscribe to view the full document.

Using GridLayout (Cont’d) <TextView android:layout_width="50dp“ android:layout_height="50dp" android:layout_column="2" android:layout_row="3" android:background="#00ff00" android:gravity="center" android:text="three" /> <TextView android:layout_width="50dp" android:layout_height="50dp" android:layout_column="0" android:layout_row="1" android:background="#0000ff" android:gravity="center" android:text="four" /> <TextView android:layout_width="50dp" android:layout_height="200dp" android:layout_column="3" android:layout_row="0" android:layout_rowSpan="4” android:background="#0077ff" android:gravity="center" android:text="five" /> </GridLayout>
Image of page 48
Using Multiple Layouts on a Screen Combining different layout methods on a single screen can create complex layouts. Remember that because a layout contains View controls and is, itself, a View control, it can contain other layouts.
Image of page 49

Subscribe to view the full document.

Using Multiple Layouts on a Screen (Cont’d) This figure demonstrates a combination of layout views used in conjunction to create a more complex and interesting screen.
Image of page 50
Using Container Control Classes Layouts are not the only controls that can contain other View controls. Although layouts are useful for positioning other View controls on the screen, they aren’t interactive. Now let’s talk about the other kind of ViewGroup , the containers. These View controls encapsulate other, simpler View types and give the user the ability to interactively browse the child View controls in a standard fashion. Much like layouts, each of these controls has a special, well-defined purpose.
Image of page 51

Subscribe to view the full document.

Using Container Control Classes (Cont’d) The types of ViewGroup containers built into the Android SDK framework include: Lists and grids ScrollView and HorizontalScrollView for scrolling ViewFlipper , ViewSwitcher , ImageSwitcher , and TextSwitcher for switching
Image of page 52
Using Data-Driven Containers Some of the View container controls are designed for displaying repetitive View controls in a particular way. Examples are: ListView GridView These containers are all types of AdapterView controls. An AdapterView control contains a set of child View controls to display data from some data source.
Image of page 53

Subscribe to view the full document.

Image of page 54
  • Summer '16

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes