主体思路
最近又接到安卓开发的任务要求,需要设计一个app的大致框架,需要带上首页,列表页,详情页。
作为一个安全小鸡仔,肯定少不了想做一个和安全相关的app。因此大致思路就是依附于国外著名安全网站thm,做一个安全wiki 。
首页
主页加载gif
具体展示
实现过程
首页操作
build.gradle 中加载
dependencies {
implementation 'com.github.bumptech.glide:glide:4.15.0' // Glide 版本
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.0' // Glide 编译器
}
按钮加载一个渐变色
在drawble中创建一个xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 渐变背景 -->
<gradient
android:startColor="#6A82FB"
android:endColor="#FC5C7D"
android:angle="45"
android:type="linear"/>
<!-- 圆角 -->
<corners android:radius="16dp"/>
<!-- 内边距 -->
<padding
android:left="20dp"
android:top="12dp"
android:right="20dp"
android:bottom="12dp"/>
</shape>
在按钮中加载
android:background=“@drawable/gradient_button”
音乐
普通服务直接使用mediaPlayer 创建音乐
mediaPlayer=MediaPlayer.create(this, R.raw._apt) ;
if (!mediaPlayer.isPlaying()){
mediaPlayer.start(); // 暂停音乐
}
列表页
首页跳转列表页
列表页采用三个按钮分别跳转
详情页面
framelayout 可以作为一个容器 展示fragment
<!-- Fragment容器 -->
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
放置三个容器,分别注册三个fragment之后可以进行操作。
之后加入退回到堆栈的代码,就可以通过返回返回上一页
// 确保将这个事务添加到回退栈中
transaction.addToBackStack(null);
// 提交事务
transaction.commit();
源码地址
https://github.com/k1t0111/app