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>
  • 相关阅读:
    JBPM使用
    eclipse spring3.X redis 整合-配置
    30分钟学会如何使用Shiro
    Linux下环境变量配置方法梳理(.bash_profile和.bashrc的区别)
    Eclipse上Maven环境配置使用 (全)
    redis未设置idle超时时间导致连接过多
    linux下搭建redis并解决无法连接redis的问题
    redis配置用户认证密码
    spring配置redis
    Linux nohup和&后台运行,进程查看及终止,进程信息输出,控制台信息输出
  • 原文地址:https://www.cnblogs.com/Chongger/p/5363282.html
Copyright © 2011-2022 走看看