zoukankan      html  css  js  c++  java
  • 今日小结 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>
  • 相关阅读:
    [JLOI2011] 飞行路线
    高精度运算模板
    Dijkstra算法模板
    [SDOI2010] 外星千足虫
    [SDOI2006] 线性方程组
    [CTSC2014] 企鹅QQ
    模板三连击:树状数组+线段树+主席树
    [ZJOI2008] 树的统计
    [国家集训队] 礼物
    [洛谷P4720] [模板] 扩展卢卡斯
  • 原文地址:https://www.cnblogs.com/Chongger/p/5363282.html
Copyright © 2011-2022 走看看