当前位置: 移动技术网 > IT编程>移动开发>Android > Android LinearLayout 线性布局开发讲解

Android LinearLayout 线性布局开发讲解

2018年11月06日  | 移动技术网IT编程  | 我要评论

张静初曝中性大片,越策越开心主持人,高光威

android布局

1、linearlayout布局(线性布局)

线性布局它是水平或者垂直来排列的布局。

详解:

首先要设置布局的排列方式它有垂直排列和水平排列,

垂直排列:android:orientation="vertical"

水平排列:android:orientation="horizontal"

(1)加权重:

android:layout_weight="值

(2)设置大小给宽高:

水平布局宽为0,垂直布局高为0.

代码案例:

xml version="1.0" encoding="utf-8">
<linearlayout xmlns:android="https://schemas.android.com/apk/res/android"
 xmlns:app="https://schemas.android.com/apk/res-auto"
 xmlns:tools="https://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".ccd"
 android:orientation="vertical"
 >

 <button
 android:layout_width="200dp"
 android:layout_height="0dp"
 android:layout_weight="2"
 android:text="左边"
 android:background="#0f0"
 />

 <button
 android:layout_width="200dp"
 android:layout_height="0dp"
 android:layout_weight="2"
 android:text="右边"
 android:layout_gravity="right"
 android:background="#aaa"
 />

 <button
 android:layout_width="200dp"
 android:layout_height="0dp"
 android:layout_weight="1"
 android:text="左边"
 android:background="#7788d6"
 />

linearlayout>

效果图:

\

=====================================================================

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网