Android的UI布局总览
openkk
13年前
<span style="font-size:15px;">android布局的目的是为了实现不同屏幕比例适配而设计的,有五种布局类:FrameLayout、LinearLayout、AbsoluteLayout、RelativeLayout和TableLayout。五大布局类的继承关系如下(以FrameLayout为例):</span> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a><br /> <a href="/misc/goto?guid=4959500254901646302">android.view.View</a><br /> <a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a><br /> android.widget.FrameLayout</p> <p> </p> <h1><span style="font-size:x-small;">一<span style="font-size:16px;">。FrameLayout简介</span></span></h1> <p><span style="font-size:14px;"> FrameLayout框架布局,在此布局下的所有对象都固定在屏幕的做上角显示,不能指定位置。最大的特点是可以添加多个子类通过<span style="font-family:Georgia;"><code>android:layout_gravity</code>来指定子类视图的位置。同一位置的子类视图处于层叠状,最上面的子类视图是最后添加的子类视图。</span></span></p> <p> 继承关系如下<span style="font-size:x-small;">:</span></p> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a><br /> <a href="/misc/goto?guid=4959500254901646302">android.view.View</a><br /> <a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a><br /> android.widget.FrameLayout</p> <p><span style="font-size:x-small;"> 它的子类:</span></p> <p><a href="/misc/goto?guid=4959500255092092311"><img alt="" src="https://simg.open-open.com/show/44231d1cb214c8eca321fc22ae5b2964.png" /></a>Known Direct Subclasses</p> <p><a href="/misc/goto?guid=4959500255173581980">AppWidgetHostView</a>, <a href="/misc/goto?guid=4959500255264028910">CalendarView</a>, <a href="/misc/goto?guid=4959500255333835043">DatePicker</a>, <a href="/misc/goto?guid=4959500255417842225">GestureOverlayView</a>, <a href="/misc/goto?guid=4959500255500981547">HorizontalScrollView</a>, <a href="/misc/goto?guid=4959500255577428494">MediaController</a>, <a href="/misc/goto?guid=4959500255681334296">ScrollView</a>, <a href="/misc/goto?guid=4959500255767580429">TabHost</a>, <a href="/misc/goto?guid=4959500255835777533">TimePicker</a>, <a href="/misc/goto?guid=4959500255923639813">ViewAnimator</a></p> <p><a href="/misc/goto?guid=4959500255092092311"><img alt="" src="https://simg.open-open.com/show/44231d1cb214c8eca321fc22ae5b2964.png" /></a>Known Indirect Subclasses</p> <p><a href="/misc/goto?guid=4959500256002826186">ImageSwitcher</a>, <a href="/misc/goto?guid=4959500256088936521">TextSwitcher</a>, <a href="/misc/goto?guid=4959500256178142080">ViewFlipper</a>, <a href="/misc/goto?guid=4959500256252067594">ViewSwitcher</a></p> <p> </p> <h1><span style="font-size:16px;">二。RelativeLayout简介</span></h1> <p><span style="font-size:14px;"> RelativeLayout相对布局,允许子元素指定他们相对于其他元素或者父元素的位置(通过ID指定),可以左右对齐,上下对齐,指定屏幕位置等形式来排列元素。</span></p> <p> 继承关系如下<span style="font-size:x-small;">:</span></p> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a><br /> <a href="/misc/goto?guid=4959500254901646302">android.view.View</a><br /> <a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a><br /> android.widget.RelativeLayout</p> <p><span style="font-size:x-small;">常用属性介绍:</span></p> <p><a href="/misc/goto?guid=4959500256355408116">android:layout_above</a><br /> Positions the bottom edge of this view above the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500256443782315">android:layout_alignBaseline</a><br /> Positions the baseline of this view on the baseline of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500256518279522">android:layout_alignBottom</a><br /> Makes the bottom edge of this view match the bottom edge of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500256590116579">android:layout_alignLeft</a><br /> Makes the left edge of this view match the left edge of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500256680156270">android:layout_alignParentBottom</a><br /> If true, makes the bottom edge of this view match the bottom edge of the parent. </p> <p><a href="/misc/goto?guid=4959500256752857105">android:layout_alignParentLeft</a><br /> If true, makes the left edge of this view match the left edge of the parent. </p> <p><a href="/misc/goto?guid=4959500256838344832">android:layout_alignParentRight</a><br /> If true, makes the right edge of this view match the right edge of the parent. </p> <p><a href="/misc/goto?guid=4959500256911246443">android:layout_alignParentTop</a><br /> If true, makes the top edge of this view match the top edge of the parent. </p> <p><a href="/misc/goto?guid=4959500256986770373">android:layout_alignRight</a><br /> Makes the right edge of this view match the right edge of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500257075578727">android:layout_alignTop</a><br /> Makes the top edge of this view match the top edge of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500257154877488">android:layout_alignWithParentIfMissing</a><br /> If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. </p> <p><a href="/misc/goto?guid=4959500257230602955">android:layout_below</a><br /> Positions the top edge of this view below the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500257307632082">android:layout_centerHorizontal</a><br /> If true, centers this child horizontally within its parent. </p> <p><a href="/misc/goto?guid=4959500257389375945">android:layout_centerInParent</a><br /> If true, centers this child horizontally and vertically within its parent. </p> <p><a href="/misc/goto?guid=4959500257467388114">android:layout_centerVertical</a><br /> If true, centers this child vertically within its parent. </p> <p><a href="/misc/goto?guid=4959500257547472752">android:layout_toLeftOf</a><br /> Positions the right edge of this view to the left of the given anchor view ID. </p> <p><a href="/misc/goto?guid=4959500257622079104">android:layout_toRightOf</a><br /> Positions the left edge of this view to the right of the given anchor view ID. </p> <p> </p> <h1><span style="font-size:x-small;"><span style="font-size:16px;">三</span>。<span style="font-size:16px;">LinearLayout简介</span></span></h1> <p><span style="font-size:x-small;"><span style="font-size:14px;"> LinearLayout线性布局,线性布局是所有布局中最常用的,他可以让其中的子元素按垂直或水平的方式排列(通过排列的方向设置),通常复杂的布局都是在LinearLayout布局中嵌套而成的</span>。</span></p> <p> 继承关系如下<span style="font-size:x-small;">:</span></p> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a></p> <p><a href="/misc/goto?guid=4959500254901646302">android.view.View</a></p> <p><a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a></p> <p>android.widget.LinearLayout</p> <p><span style="font-size:14px;"> 他的子类有:</span></p> <p><a href="/misc/goto?guid=4959500257738757810"><img alt="" src="https://simg.open-open.com/show/44231d1cb214c8eca321fc22ae5b2964.png" /></a>Known Direct Subclasses</p> <p><a href="/misc/goto?guid=4959500257815850121">NumberPicker</a>, <a href="/misc/goto?guid=4959500257892260675">RadioGroup</a>, <a href="/misc/goto?guid=4959500257965979512">SearchView</a>, <a href="/misc/goto?guid=4959500258057267679">TabWidget</a>, <a href="/misc/goto?guid=4959500258126687450">TableLayout</a>, <a href="/misc/goto?guid=4959500258215934347">TableRow</a>, <a href="/misc/goto?guid=4959500258295450970">ZoomControls</a></p> <p> </p> <h1>四。AbsoluteLayout简介</h1> <p> AbsoluteLayout绝对布局。指定了子元素的x/y坐标值,并显示在屏幕上。该布局没有屏幕边框,允许元素之间互相重叠,在实际中不提倡使用这种布局,因为固定了位置,所以在屏幕旋转式会有不完整。</p> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a></p> <p> 继承关系如下<span style="font-size:x-small;">:</span><br /> <a href="/misc/goto?guid=4959500254901646302">android.view.View</a><br /> <a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a><br /> android.widget.AbsoluteLayout</p> <p> 他的子类有:</p> <p><a href="/misc/goto?guid=4959500258402043318"><img alt="" src="https://simg.open-open.com/show/44231d1cb214c8eca321fc22ae5b2964.png" /></a>Known Direct Subclasses</p> <p><a href="/misc/goto?guid=4959500258479157491">WebView</a></p> <p><strong>*************This class is deprecated.</strong><br /> Use <code><a href="/misc/goto?guid=4959500255092092311">FrameLayout</a></code>, <code><a href="/misc/goto?guid=4959500258572555197">RelativeLayout</a></code>or a custom layout instead.</p> <p> </p> <h1>五。TableLayout简介</h1> <p> TableLayout表格布局。将子元素的位置分配到行或列中,TableLayout布局有许多TableRow(行)组成,但没有列的概念,列是又行中的控件数目来决定的,TableLayout也是常有布局。TableLayout不会显示行、列、单元格的边框线。</p> <p> 继承关系如下<span style="font-size:x-small;">:</span></p> <p><a href="/misc/goto?guid=4959500254817842313">java.lang.Object</a><br /> <a href="/misc/goto?guid=4959500254901646302">android.view.View</a><br /> <a href="/misc/goto?guid=4959500254984126697">android.view.ViewGroup</a><br /> <a href="/misc/goto?guid=4959500257738757810">android.widget.LinearLayout</a><br /> android.widget.TableLayout</p> <p>他的子类有:</p> <p><a href="/misc/goto?guid=4959500258694412766">android:collapseColumns</a><br /> <a href="/misc/goto?guid=4959500258772553261">setColumnCollapsed(int,boolean)</a><br /> The zero-based index of the columns to collapse. </p> <p><a href="/misc/goto?guid=4959500258855144554">android:shrinkColumns</a><br /> <a href="/misc/goto?guid=4959500258934847530">setShrinkAllColumns(boolean)</a><br /> The zero-based index of the columns to shrink. </p> <p><a href="/misc/goto?guid=4959500259022535205">android:stretchColumns</a><br /> <a href="/misc/goto?guid=4959500259092032342">setStretchAllColumns(boolean)</a><br /> The zero-based index of the columns to stretch. <br /> <br /> 转自:<a href="/misc/goto?guid=4959500259266298812" target="_blank">http://www.cnblogs.com/zhxiang/archive/2012/01/03/2311311.html</a></p>