app门户界面设计
*项目总体介绍
总体内容:此项目是安卓APP的门户界面框架设计,包含了4个table页面,能简单实现table页面之间的点击切换功能。
**使用到的技术:**使用布局(layout)和分段(fragment),对控件进行点击监听。
页面总体效果:
Layout布局文件
top.xml页面的设计
新建一个名为top.xml的文件,拖一个LinearLayout,然后在拖一个textView在LinearLayout的下面,具体参数设置如下:
实现效果如下:
buttom.xml页面的设计
新建一个bottom.xml的文件,在布局界面拖一个横向排列的LinearLayout,然后在这个LinearLayout下面拖四个纵向排列的LinearLayout进来,在每个LinearLayout中加入ImageView和textview
具体设置如下:
具体效果如下图:
activity_main.xml页面的设计
拖一个LinearLayout,再拖一个FragmentLayout将其id改为content,在co用include引入之前的顶部界面top.xml以及底部界面bottom.xml
四个Fragment.xml
具体效果如下:
Java文件
四个Fragment.java类文件
四个Fragment.java类文件与四个Fragment.xml一一对应
caidan部分的Java代码
package com.example.homework;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment_zhongxin extends Fragment {
public Fragment_zhongxin() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_zhongxin, container, false);
}
}
meiti部分的Java代码
package com.example.homework;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment_meiti extends Fragment {
public Fragment_meiti() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_meiti, container, false);
}
}
tonghua部分代码
package com.example.homework;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment_tonghua extends Fragment {
public Fragment_tonghua() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_tonghua, container, false);
}
}
zhongxin部分代码
package com.example.homework;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment_zhongxin extends Fragment {
public Fragment_zhongxin() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_zhongxin, container, false);
}
}
MainActivity
根据写的四个Fragment类文件new四个对象
声明Fragment管理器
初始化Fragment
创建四个LinearLayout对象
隐藏效果
图标变色
声明四个Imageview对象
使Imageview对象指向bottom.xml中的四个图片
隐藏
onClick函数