[Android学习] 3.运用碎片进行设置界面的模块切换

运用动态碎片切换,ListView RecyclerView控件以及wifiManager实现基本的设置页面和无线网络页面,总结加深锻炼。

设计界面图

 

 基本思路分析

1.首先固定部分在主布局中展现,中间部分通过引入FrameLayout/布局进行动态碎片的切换。

2.按键背景图,选中按键切换效果。

3.返回键返回上页面。

代码部分

布局文件

主布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background"
        android:orientation="vertical">
        //-------------设置那一行----------------//

        //------------------下划线一行-----------------------//

        <LinearLayout
            android:id="@+id/top_bar"
            android:layout_width="match_parent"
            android:layout_height="135dp"
            android:layout_marginTop="50dp"
            android:layout_weight="1"
            android:orientation="horizontal">

            //"《"那一行

            <Button
                android:id="@+id/Button_back"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:background="@null"
                android:gravity="center"
                android:text='&lt;'
                android:textColor="#181919"
                android:textSize="40dp" />

            //"设置"字符设定

            <TextView
                android:id="@+id/txt_top"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_marginRight="150dp"
                android:layout_weight="7"
                android:gravity="center"
                android:text="设置"
                android:textColor="#181919"
                android:textSize="60dp" />

        </LinearLayout>

        <FrameLayout
            android:id="@+id/fg_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="5"
            android:background="@drawable/background"
            android:layout_margin="80dp"/>

        <View
            android:id="@+id/bottom_bar"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:background="#181919" />

        //------------------输入源一行------------------------//

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:layout_weight="1"
            android:orientation="horizontal"
            android:layout_gravity="center"
            android:gravity="center">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@null"
                android:gravity="center"
                android:text="输入源"
                android:textColor="#181919"
                android:textSize="25dp" />

       
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值