布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="androidpermission.com.bw.test.day0630.MainActivity"
    android:orientation="vertical"
    >



    <LinearLayout
        android:background="#28B8F7"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"

        >

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:id="@+id/rg"
            android:orientation="horizontal"
            android:gravity="center_horizontal"
            android:padding="10dp"
            >
            <ImageButton
                android:layout_marginRight="50dp"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:id="@+id/iv1"
                android:src="@mipmap/ic_launcher"
                />

            <RadioButton
                 android:id="@+id/rb1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:button="@null"
                android:text="报纸版面"
                android:textSize="25dp"
                />
            <RadioButton
                android:id="@+id/rb2"
                android:layout_marginLeft="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:button="@null"
                android:text="本期目录"
                android:textSize="25dp"
                />

            <ImageButton

                android:layout_marginLeft="50dp"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:id="@+id/iv2"
                android:src="@mipmap/ic_launcher"
                />

        </RadioGroup>
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/group" />


</LinearLayout>
在Android Studio中,布局文件是用于定义用户界面布局的XML文件。这些文件通常位于项目的`res/layout`目录下。布局文件中的XML代码描述了Android应用界面的各个组件(如按钮、文本框、图片等)以及它们之间的布局关系。 布局文件包含以下几个主要部分: 1. 根布局(Root Layout):这是布局文件中的最外层容器,通常是LinearLayout、RelativeLayout、FrameLayout等。它定义了子视图的排列方式。 2. 布局属性:这些属性定义了布局的方向、大小、间距、对齐方式等。例如,LinearLayout可以通过`android:orientation`属性设置其子视图的排列方向为水平(`horizontal`)或垂直(`vertical`)。 3. 视图组件:这是布局中实际可见的UI元素,如Button、TextView、ImageView等。每个视图组件都有自己的属性集,如id、text、src、background等,这些属性用于定义组件的外观和行为。 4. 嵌套布局布局文件中可以嵌套使用其他布局,形成复杂的布局结构。例如,一个LinearLayout内可以包含一个RelativeLayout,而RelativeLayout内部又可以包含多个TextView或Button等。 Android Studio为布局文件提供了一个可视化的编辑器,使得开发者可以拖放组件来构建布局,并且可以实时预览布局效果。同时,开发者也可以直接编辑XML代码来进行更细致的布局调整。 布局文件的命名通常遵循一定的规范,如activity_main.xml、fragment_home.xml等,以便于理解和维护。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值