Android开发项目——智能农业(知识点整理回顾)

前言:智能农业这个项目可以说是大多都是我们自己完成的。是对于前一个多月Android学习的一个检验,同时也是对我们成绩的一个凭据。意义非常重大。

一、对于布局方面

下面我放两张例图,是我认为在布局上对我有难度的点
这里写图片描述
这里写图片描述
可以看到页面最下方的分别是首页,设置和帮助。而各自的页面上又有各自的内容,所以我们就要用到Fragment和ViewPager现结合,来实现页面的滑动和点击翻页。(由于布局很多,我就挑着些重要的说)
1.首先定义一个Activity类来写页面下方的主页,设置和帮助。这是在三个页面固定不动的。

<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:orientation="vertical"
    tools:context="com.example.myapplication15.classActivity">

    <android.support.v4.view.ViewPager
        android:id="@+id/class_viewpager"
        android:layout_width="match_parent"
        android:layout_height="570dp">
    </android.support.v4.view.ViewPager>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/class_viewpager"
        android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/main_ll"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/b1"
            android:layout_gravity="center"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="首页"
            android:textSize="15sp"
            android:layout_gravity="center"/>
    </LinearLayout>

        <LinearLayout
            android:id="@+id/set_ll"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/b2"
                android:layout_gravity="center"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="设置"
                android:textSize="15sp"
                android:layout_gravity="center"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/help_ll"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/b3"
                android:layout_gravity="center"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="帮助"
                android:textSize="15sp"
                android:layout_gravity="center"/>
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

2.接下来就是上面三个Fragment页面用使用Fragment和ViewPager来实现页面的滑动和点击翻页,在这里面我们就是要对布局页面进行填充了。(我用首页来举例)

  1. 在布局文件里对首页的进行代码编程
<FrameLayout 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="com.example.myapplication15.fragment.MainFragment">

    <!-- TODO: Update blank fragment layout -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:gravity="center"
            android:text="智能农业"
            android:textColor="#28c014"
            android:textSize="30sp" />

        <android.support.v4.view.ViewPager
            android:id="@+id/title_pic_viewpager"
            android:layout_width="match_parent"
            android:layout_height="150dp">

        </android.support.v4.view.ViewPager>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值