展会信息港展会大全

Android ApiDemos示例解析(149):Views->Layouts->LinearLayout->9. Layout Weight
来源:互联网   发布日期:2015-10-13 17:05:40   浏览:1421次  

导读:本例介绍了layout_weight 的用法,layout_weight 用法前面已介绍过:如Android ApiDemos示例解析(147):Views->Layouts->LinearL...

本例介绍了layout_weight 的用法,layout_weight 用法前面已介绍过:如Android ApiDemos示例解析(147):Views->Layouts->LinearLayout->7. Fill Parent

和 Android ApiDemos示例解析(143):Views->Layouts->LinearLayout->3. Vertical (Padded)。

本例使用了一个 ListView 和 Button ,将ListView 的weight 设为1, 而 Button 没有权重(为0) ,因此ListView 将占据所有除Button之外的所有空间:

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

android:orientation=”vertical”

android:layout_width=”match_parent”

android:layout_height=”match_parent”>

<ListView android:id=”@+id/list”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:layout_weight=”1.0″ />

<Button

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:text=”@string/linear_layout_9_button” />

</LinearLayout>

\

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港