当前位置: 移动技术网 > 移动技术>移动开发>Android > android studio布局文件详解

android studio布局文件详解

2020年07月09日  | 移动技术网移动技术  | 我要评论

详解如下

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=".MainActivity">

<LinearLayout  //设置布局管理器为LinearLayout
    android:layout_width="match_parent"  //设置当前组件宽度。match_parent表示充满整个父元素。
    android:layout_height="match_parent" //设置组件高度。
    android:layout_marginEnd="16dp"      //距离边缘的位置信息
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginStart="16dp"
    android:layout_marginTop="8dp"
    android:orientation="vertical"  //设置组件内容的排列方式为横向还是竖向。
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <TextView
        android:id="@+id/tvSMPTitle"  //组件的ID
        android:layout_width="match_parent"
        android:layout_height="wrap_content"  //组件多大就是多大。
        android:text="简单的MP3播放器" />      //组件添加文字

    <Button
        android:id="@+id/bt_play_or_pause"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="播放" />  //按钮设置显示文字

    <Button
        android:id="@+id/btSMPStop"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="暂停" />
</LinearLayout>

</android.support.constraint.ConstraintLayout>

本文地址:https://blog.csdn.net/ZZ_skate/article/details/107168131

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网