Android第二天

View是所有的视图都有的属性

android:layout_width=    设置 宽度

android:layout_height=    设置  高度

android:orientation:可以设置布局的方向

android:gravity:用来控制组件的对齐方式

android:layout_width="match_parent"
android:layout_height="match_parent"
布局: 

match_parent 或fill_parent        fill_parent   已经过时了

填充满父布局

wrap_content       

内容包裹我内部的内容有多大就显示多大

android:id=“@+id    给一个属性起名字

android:id="@+id/bbb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_centerInParent="true"

对齐方式

android:layout_margin =“dp” 外边距 四个方向都有

android:layout_marginLeft =“dp” 外左边距

android:layout_marginTop =“dp” 外上边距

android:layout_marginRight =“dp” 外右边距

android:layout_marginButtom =“dp” 外下边距


  android:padding=“dp”

  android:paddingLeft= “dp”左内边距

  android:paddingRight= “dp”右内边距

  android:paddingTop= “dp”上

  android:paddingButtom= “dp”下


五大布局 :

线性布局(LinearLayout):按照垂直或者水平方向布局的组件。

线性布局是Android开发中最常见的一种布局方式,它是按照垂直或者水平方向来布局,通过“android:orientation”属性可以设置线性布局的方向。属性值有垂直(vertical)和水平(horizontal)两种。

帧布局(FrameLayout):组件从屏幕左上方布局组件。

帧布局是从屏幕的左上角(0,0)坐标开始布局,多个组件层叠排列,第一个添加的组件放到最底层,最后添加到框架中的视图显示在最上面。上一层的会覆盖下一层的控件,只要设置好他们的位置即可。

表格布局(TableLayout):按照行列方式布局组件。

表格布局是一个ViewGroup以表格显示它的子视图(view)元素,即行和列标识一个视图的位置。

相对布局(RelativeLayout):相对其它组件的布局方式。

绝对布局(AbsoluteLayout):按照绝对坐标来布局组件。


android:layout_alignLeft=“@id/button” 参数是参照物视图的id 作用于 参照物视图左边对齐

android:layout_alignRight=“@id/button” 参数是参照物视图的id 作用于 参照物视图右边对齐

android:layout_alignTop=“@id/button” 参数是参照物视图的id 作用于 参照物视图上边对齐

android:layout_alignButtom=“@id/button” 参数是参照物视图的id 作用于 参照物视图下边对齐


android:layout_toLeftof=“@id/button”  在参照物视图的 左侧

android:layout_toRightof=“@id/button”  在参照物视图的右侧

android:layout_above=“@id/button” 在参照物视图的上侧

android:layout_below=“@id/button”在参照物视图的下册











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值