Fill Model

 

Let’s imagine a row of widgets, such as a pair of radio buttons. These widgets have a “natural” size based on their text. Their combined sizes probably do not exactly match the width of the Android device’s screen – particularly since screens come in various sizes. We then have the issue of what to do with the remaining space.

All widgets inside a must supply and properties to help address this issue. These properties’ values have three flavors:

• You can provide a specific dimension, such as , to indicate the widget should take up exactly 125 pixels.

• You can provide , which means the widget should fill up its natural space unless that is too big, in which case Android can use word wrap as needed to make it fit.

• You can provide , which means the widget should fill up all available space in its enclosing container after all other widgets are taken care of.

The latter two flavors are the most common, as they are independent of screen size, allowing Android to adjust your view to fit the available space.

 

Weight

 

What happens if we have two widgets that should split the available free space? For example, suppose we have two multi‑line fields in a column, and we want them to take up the remaining space in the column after all other widgets have been allocated their space.

To make this work, in addition to setting (for rows) or (for columns) to , you must also set . This property indicates what proportion of the free space should go to that widget. If you set to be the same value for a pair of widgets (e.g., 1), the free space will be split evenly between them. If you set it to be 1 for one widget and 2 for another widget, the second widget will use up twice the free space that the first widget does, and so on.

 








Дата добавления: 2015-05-16; просмотров: 766;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.006 сек.