Five Android layouts
程序员文章站
2022-07-21 21:17:54
线性布局: 相对布局: ......
线性布局:
1 <?xml version="1.0" encoding="utf-8"?> 2 <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 <!-- 上下左右全部填充100dp最终是已后加载的为准 --> 7 <textview 8 android:id="@+id/tv_number" 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 android:layout_marginleft="30dp" 12 android:layout_margin="100dp" 13 android:text="请输入电话号码"/> 14 <edittext 15 android:layout_width="match_parent" 16 android:layout_height="wrap_content" 17 android:hint="请输入电话号码" 18 /> 19 20 21 <button 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:text="拨打" 25 /> 26 27 </linearlayout>
相对布局:
1 <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 tools:context=".mainactivity" > 6 <!-- 相对布局默认都是从左上角开始布局 --> 7 <textview
8 android:id="@+id/tv_number" 9 android:layout_width="wrap_content" 10 android:layout_height="wrap_content" 11 android:text="请输入电话号码" /> 12 13 <edittext 14 android:id="@+id/et_number" 15 android:layout_width="match_parent" 16 android:layout_height="wrap_content" 17 android:hint="请输入电话号码" 18 android:layout_below="@id/tv_number" 19 /> 20 21 <button 22 android:id="@+id/btn_number" 23 android:layout_width="wrap_content" 24 android:layout_height="wrap_content" 25 android:text="拨打" 26 android:layout_below="@id/et_number" 27 /> 28 29 <button 30 android:layout_width="wrap_content" 31 android:layout_height="wrap_content" 32 android:text="按钮" 33 android:layout_torightof="@id/btn_number" 34 android:layout_below="@id/et_number" 35 /> 36 37 38 </relativelayout>
推荐阅读
-
将Eclipse中的项目迁移到Android Studio中的方法
-
最快速的Android开发环境搭建ADT-Bundle及Hello World
-
Android Studio如何使用aar依赖包?
-
Android使用TabLayout+Fragment实现顶部选项卡
-
Android 7.0及以上使用OpenCL
-
使用Kotlin开发Android应用教程
-
Android 自定义输入手机号自动添加分隔符
-
Android Kotlin开发实例(Hello World!)及语法详解
-
Build Assimp library for Android
-
Android md5加密与php md5加密一致详解