网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

android基础之LinearLayout布局-创新互联

LinearLayout布局:

创新互联专业为企业提供古雷港网站建设、古雷港做网站、古雷港网站设计、古雷港网站制作等企业网站建设、网页设计与制作、古雷港企业网站模板建站服务,十年古雷港做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="horizontal"

   >

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button1"

  />

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button2"

  />

  android:layout_height="wrap_content"

  android:layout_width="wrap_content"

  android:text="Button3"

  />

android基础之LinearLayout布局

LinearLayout布局的嵌套:

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="horizontal"

   >

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button1"

  />

 android:layout_width="fill_parent"

 android:layout_height="wrap_content"

 >

 

 android:text="Button2"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

/>

  android:layout_height="wrap_content"

  android:layout_width="wrap_content"

  android:text="Button3"

  />

android基础之LinearLayout布局

Layout_weight属性:

所有的组件都有这个属性,不设置的情况下默认为0,其属性表示当前有多大视图就占据多大视图

如果其值高于0,则表示将父视图中的可用空间进行分割

示例代码如下:

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="vertical"

   >

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button1"

  android:layout_weight="1"

  />

  android:text="button4"

  android:layout_height="wrap_content"

  android:layout_width="wrap_content"

  android:layout_weight="1"

  />

android基础之LinearLayout布局

线性布局中常用的属性:

1:gravity:每个组件默认其值为左上角对齐。这个属性可以调整组件对齐方式比如如何向左。向右或者居中对齐等、

2:padding边距的填充,也称内边距.指的是当前布局与包含的组件之间的边距

android:paddingTop

android:paddingBottom

android:paddingLeft

android:paddingRight

android:padding表示周围四方向个边距统一调整

3:layout_margin:外边距。指的是与其他组件之间的边距。

android:layout_marginTop

android:layout_marginBottom

android:layout_marginLeft

android:layout_marginRight

android:layout_margin表示设置四方向边距统一调整

一个比较综合的例子:

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="vertical"

   >

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button1"

  android:layout_gravity="bottom"

  android:paddingTop="10dp"

  />

  android:text="button4"

  android:layout_height="wrap_content"

  android:layout_width="wrap_content"

  android:layout_gravity="bottom"

  android:layout_marginLeft="50dp"

  android:layout_marginTop="30dp"

  />

  android:text="button2"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:layout_gravity="bottom"

  android:paddingLeft="60dp"

  android:paddingBottom="60dp"

  />

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button3"

  android:layout_gravity="right"

  />

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="button6"

  android:layout_gravity="right"

  android:layout_marginRight="40dp"

  android:layout_marginTop="40dp"

  />

android基础之LinearLayout布局

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:android基础之LinearLayout布局-创新互联
浏览地址:http://bjjierui.cn/article/deodih.html

其他资讯