Android入门之相对布局(RelativeLayout)

简介: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="30dp"
    >
    <TextView
        android:id="@+id/lableView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="登陆界面" />
    
    <EditText 
        android:id="@+id/usernameText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:hint="username"
        android:layout_below="@id/lableView"/>
    
    <EditText 
        android:id="@+id/passwordText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/usernameText"
        android:layout_alignRight="@id/usernameText"
        android:hint="password"
        android:inputType="textPassword"
        android:layout_below="@id/usernameText"/>
    
    <Button 
        android:id="@+id/cancelButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/passwordText"
        android:layout_alignParentRight="true"
        android:text="取消"
        />
    
    <Button 
        android:id="@+id/okButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/cancelButton"
        android:layout_toLeftOf="@id/cancelButton"
        android:text="确定"/>

</RelativeLayout>

效果如下:


目录
相关文章
|
1月前
|
XML Android开发 数据格式
android点击FrameLayout、LinearLayout等父布局没响应的原因以及解决方案
android点击FrameLayout、LinearLayout等父布局没响应的原因以及解决方案
34 2
|
1月前
|
Android开发
Android梅花布局
Android梅花布局
23 1
|
2月前
|
Android开发
android 布局常见调整手段,怎样查看margin,padding等等
android 布局常见调整手段,怎样查看margin,padding等等
19 0
|
4天前
|
开发框架 搜索推荐 .NET
Android之ListActivity 布局与数据绑定
Android之ListActivity 布局与数据绑定
10 0
|
1月前
|
XML Android开发 数据格式
Android六大布局
Android六大布局
37 1
|
1天前
|
存储 传感器 Android开发
构建高效Android应用:从优化布局到提升性能
【5月更文挑战第13天】 在竞争激烈的移动应用市场中,一个高效的Android应用不仅需要具备直观的用户界面和丰富的功能,还要确保流畅的性能和快速的响应时间。本文将深入探讨如何通过优化布局设计、减少资源消耗以及利用系统提供的API来提升Android应用的性能。我们将分析布局优化的策略,讨论内存使用的常见陷阱,并介绍异步处理和电池寿命的考量。这些技术的综合运用将帮助开发者构建出既美观又高效的Android应用。
|
4天前
|
Android开发 容器
Android Layout 布局
Android Layout 布局
10 1
|
5天前
|
搜索推荐 Android开发
自定义Android标题栏TitleBar布局
自定义Android标题栏TitleBar布局
|
5天前
|
XML Android开发 数据格式
Android五大布局对象---FrameLayout,LinearLayout ,Absolute
Android五大布局对象---FrameLayout,LinearLayout ,Absolute
|
5天前
|
Android开发
Android游戏引擎AndEngine入门资料
Android游戏引擎AndEngine入门资料
12 3