• 今日小结 4.7


    • 绑定照片到RecyclerView中 —— OK  但是非常卡,基本不能用
    • Fragment 动态调用 ——OK
    • 布局的嵌套,底部按钮四个按钮的布局文件设计 ,线性布局的权重设置 —— OK

    1.Fragment将每一个视图部分(Fragment)的视图设置(Fragment layout)和程序编写(XXFragment.class)相分开 ,

    提高了代码的可读性,复用性和维护性

    2.使用RelativeLayout + LinearLayout 嵌套完成四个按钮底部均匀放置,

    使用RelativeLayout完成放置底部操作 

    android:layout_alignParentBottom="true"

    设置权重,完成四个按钮的均匀对齐

    android:layout_weight="1"
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    
        <LinearLayout
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <ImageButton
                android:id="@+id/ib_bottombar_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@android:drawable/ic_menu_add"
                android:scaleType="center" />
    
            <ImageButton
                android:id="@+id/ib_bottombar_edit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@android:drawable/ic_menu_edit"
    
                android:scaleType="center" />
    
            <ImageButton
                android:id="@+id/ib_bottombar_delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
    
                android:background="@android:drawable/ic_menu_delete"
    
                android:scaleType="center" />
    
            <ImageButton
                android:id="@+id/ib_bottombar_more"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
    
                android:background="@android:drawable/ic_menu_more"
                android:scaleType="center" />
    
            </LinearLayout>
    
    
    </RelativeLayout>

    3.可以使用 include完成布局嵌套,使得主布局activity_main显得简洁

    以下的主布局由三个部分构成

    (1)标题的fragment (包含一个左上角的menu,一个居中显示的text标题)

    (2)(include) 底端四个按钮的布局

    (3)FramLayout 四个按钮分别对应的四个界面fragment 切换显示

    <?xml version="1.0" encoding="utf-8"?>
    <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:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="edu.dhu.lichong.fragmentdemo.MainActivity">
    
       <fragment
           android:id="@+id/id_fragment_title"
           android:name="edu.dhu.lichong.fragmentdemo.TitleFragment"
           android:layout_width="match_parent"
           android:layout_height="45dp"/>
        <include
            android:id="@+id/id_ly_bottombar"
            layout="@layout/bottombar"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            />
    
        <FrameLayout
            android:id="@+id/fragment_content"
            android:layout_above="@+id/id_ly_bottombar"
            android:layout_below="@+id/id_fragment_title"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
        </FrameLayout>
    </RelativeLayout>
  • 相关阅读:
    判断是否是三角形,三角形面积,三角形内外切圆半径和面积
    输入从a加到b的两个数字
    九九乘法表
    某公司销售员工的年终奖根据该员工的年销售总额s提成,年销售总额超过1万元才提成,超过部分提成比例如下:
    判断是否是闰年?
    从键盘上输入三个点的坐标值(1,1)、(2,4)、(3,2),编程求该三角形的面积。
    输入一个正方形的边长,输出正方形的外接圆和内接圆的面积。
    .输入一个4位正整数,以相反的次序输出,例如,输入1234,输出为4321。
    SecoClient在win10系统中连接失败解决方案
    PHP 关于判断输入日期是否合法
  • 原文地址:https://www.cnblogs.com/Chongger/p/5363282.html
Copyright © 2020-2023  润新知