-
安卓各种框架的依赖包
2017-11-12 12:56:39OkHttpClient依赖的架包: compile 'com.squareup.okhttp3:okhttp:3.4.1' XListView的依赖包 compile 'com.github.ForgiveAll:Xlistview:v1.0' maven{url'https://jitpack.io'} imageLoade
OkHttpClient依赖的架包:
compile 'com.squareup.okhttp3:okhttp:3.4.1'
XListView的依赖包
compile 'com.github.ForgiveAll:Xlistview:v1.0'
maven{url'https://jitpack.io'}
imageLoader的依赖包
'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
二维码依赖包:
compile 'com.github.jwkj:LibZXing:v1.0.4'maven { url 'https://jitpack.io' }
http://blog.csdn.net/qq137722697/article/details/74012495
解决.Jar文件打不开
https://www.waitalone.cn/win10-jar-open.html
Banner自动轮播图框架的依赖:
compile 'com.youth.banner:banner:1.4.9'
自动轮播图的权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="200dp" />
RecyclerView 的依赖:
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
SimpleDraweeView加载图片的依赖:
compile 'com.facebook.fresco:fresco:1.5.0'
interceptor(拦截器)的依赖:
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
Gson 的依赖:
compile 'com.google.code.gson:gson:2.4' -
安卓左右滑动框架——纯手写,不用依赖别人的框架啦
2020-11-03 16:45:55//当前view被选择的时候,改变底部菜单图片,文字颜色 switch (position) { case 0: tv_home.setTextColor(0xff1B940A); break; case 1: tv_address.setTextColor(0xff1B940A); break; case 2: tv_friend....1.先来看看效果吧!
2.实现方法:
(1)首先新建一个 空Activity,设为主activity。HomeActivity.java
public class HomeActivity extends AppCompatActivity implements View.OnClickListener, ViewPager.OnPageChangeListener{ // 底部菜单5个Linearlayout private LinearLayout ll_home; private LinearLayout ll_address; private LinearLayout ll_friend; private LinearLayout ll_setting; private LinearLayout ll_set; // 底部菜单5个菜单标题 private TextView tv_home; private TextView tv_address; private TextView tv_friend; private TextView tv_setting; private TextView tv_set; // 中间内容区域 private ViewPager viewPager; // ViewPager适配器ContentAdapter private ContentAdapter adapter; private List<View> views; private void initEvent() { // 设置按钮监听 ll_home.setOnClickListener(this); ll_address.setOnClickListener(this); ll_friend.setOnClickListener(this); ll_setting.setOnClickListener(this); ll_set.setOnClickListener(this); //设置ViewPager滑动监听 viewPager.setOnPageChangeListener(this); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // 底部菜单5个Linearlayout this.ll_home = findViewById(R.id.ll_home); this.ll_address = findViewById(R.id.ll_address); this.ll_friend = findViewById(R.id.ll_friend); this.ll_setting = findViewById(R.id.ll_setting); this.ll_set= findViewById(R.id.ll_set); // 底部菜单5个菜单标题 this.tv_home = findViewById(R.id.tv_home); this.tv_address = findViewById(R.id.tv_address); this.tv_friend = findViewById(R.id.tv_friend); this.tv_setting = findViewById(R.id.tv_setting); this.tv_set= findViewById(R.id.tv_set); // 中间内容区域ViewPager this.viewPager = findViewById(R.id.vp_content); // 适配器 View page_01 = View.inflate(HomeActivity.this, R.layout.page_01, null); View page_02 = View.inflate(HomeActivity.this, R.layout.page_02, null); View page_03 = View.inflate(HomeActivity.this, R.layout.page_03, null); View page_04 = View.inflate(HomeActivity.this, R.layout.page_04, null); View page_05 = View.inflate(HomeActivity.this, R.layout.page_05, null); views = new ArrayList<>(); views.add(page_01); views.add(page_02); views.add(page_03); views.add(page_04); views.add(page_05); this.adapter = new ContentAdapter(views); viewPager.setAdapter(adapter); initEvent(); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.ll_home: tv_home.setTextColor(0xff1B940A); viewPager.setCurrentItem(0); break; case R.id.ll_address: tv_address.setTextColor(0xff1B940A); viewPager.setCurrentItem(1); break; case R.id.ll_friend: tv_friend.setTextColor(0xff1B940A); viewPager.setCurrentItem(2); break; case R.id.ll_setting: tv_setting.setTextColor(0xff1B940A); viewPager.setCurrentItem(3); break; case R.id.ll_set: tv_set.setTextColor(0xff1B940A); viewPager.setCurrentItem(4); default: break; } } private void restartBotton() { // TextView置为白色 tv_home.setTextColor(0xffffffff); tv_address.setTextColor(0xffffffff); tv_friend.setTextColor(0xffffffff); tv_setting.setTextColor(0xffffffff); tv_set.setTextColor(0xffffffff); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { restartBotton(); //当前view被选择的时候,改变底部菜单图片,文字颜色 switch (position) { case 0: tv_home.setTextColor(0xff1B940A); break; case 1: tv_address.setTextColor(0xff1B940A); break; case 2: tv_friend.setTextColor(0xff1B940A); break; case 3: tv_setting.setTextColor(0xff1B940A); break; case 4: tv_set.setTextColor(0xff1B940A); break; default: break; } } @Override public void onPageScrollStateChanged(int state) { } }
有报红的先不用理它。
(2)activity_home.xml
<?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" tools:context="com.example.myclient.HomeActivity"> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <androidx.viewpager.widget.ViewPager android:id="@+id/vp_content" android:layout_width="match_parent" android:background="#ffffff" android:layout_height="0dp" android:layout_weight="1" > </androidx.viewpager.widget.ViewPager> <include layout="@layout/activity_bottom" /> </LinearLayout> </RelativeLayout>
(3)activity_bottom.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="35dp" android:background="#CBB4F5" > <LinearLayout android:id="@+id/ll_home" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/iv_home" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="页面1" android:textSize="20dp" android:textColor="#1B940A" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:id="@+id/ll_address" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/iv_address" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_address" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="页面2" android:textColor="#ffffff" android:textSize="20dp" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:id="@+id/ll_friend" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/iv_friend" android:layout_width="53dp" android:layout_height="match_parent" /> <TextView android:id="@+id/tv_friend" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="页面3" android:textSize="20dp" android:textColor="#ffffff" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:id="@+id/ll_setting" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/iv_setting" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_setting" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="页面4" android:textColor="#ffffff" android:textSize="20dp" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:id="@+id/ll_set" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/iv_set" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_set" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="页面5" android:textColor="#ffffff" android:textSize="20dp" android:textStyle="bold" /> </LinearLayout> </LinearLayout>
(4)回到HomeActivity.java,会看到ContentAdapter报红,这里新建一个ContentAdapter.java类
public class ContentAdapter extends PagerAdapter { private List<View> views; public ContentAdapter(List<View> views) { this.views = views; } @Override public int getCount() { return views.size(); } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == arg1; } @Override public Object instantiateItem(ViewGroup container, int position) { View view = views.get(position); container.addView(view); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView(views.get(position)); } }
(5)page_01~05的报红,新建5个Layout resource file(xml),分别命名为page_01.xml、page_02.xml…以此类推
page_01.xml的内容和其他的有点点不同,因为嵌入fragment会让APP更灵活方便。
以下是page_01.xml代码:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_gravity="center" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent"> <!--下面是fragment--> <fragment android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:name="com.example.myclient.TestFragment" /> </LinearLayout>
TestFragment报红了是不是?
新建一个TestFragment.java,包名先不用管。public class TestFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.fragment_test, null); Button btn_test=view.findViewById(R.id.btn_test); btn_test.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(),"我是第一页",Toast.LENGTH_LONG).show(); } }); return view; } }
fragment_test.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_gravity="center" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/btn_test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="点我试试"/> </LinearLayout>
到这一步,如果page_01.xml里的 android:name="com.example.myclient.TestFragment"还报红,就把com.example.myclient.TestFragmen删掉,然后你试试手打com. 它就会自己出来TestFragment的选项,这时候点击这个选项就可以啦
page_02.xml的和另外三个是一样的,除了展现的文字不一样。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_gravity="center" android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二页"/> </LinearLayout>
manifest也给吧
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.myclient"> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="AllowBackup,GoogleAppIndexingWarning"> <activity android:name=".HomeActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
3.总结与教训
要把这个滑动的框架结合自己的APP,一定要先提前搭好框架再做别的功能,否则…嘿嘿,你懂得。
-
安卓的依赖
2018-04-16 15:37:48//Butterknife依赖 compile 'com.jakewharton:butterknife:8.8.1' //imageLoader的依赖包 compile '...//自动轮播图框架的依赖: compile 'com.youth.bann...//Butterknife依赖 compile 'com.jakewharton:butterknife:8.8.1' //imageLoader的依赖包 compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' //自动轮播图框架的依赖: compile 'com.youth.banner:banner:1.4.9' //RecyclerView 的依赖: compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' //SimpleDraweeView加载图片的依赖: compile 'com.facebook.fresco:fresco:1.5.0' //interceptor的依赖: compile 'com.squareup.okhttp3:logging-interceptor:3.9.0' //Gson 的依赖: compile 'com.google.code.gson:gson:2.8.2' //Banner的依赖: compile 'com.youth.banner:banner:1.4.10' //XBanner的依赖: compile 'com.xhb:xbanner:1.3.0' //Fresco依赖: compile 'com.facebook.fresco:fresco:1.5.0' //OKHttp依赖 compile 'com.squareup.okhttp3:okhttp:3.9.0' //OKHttp拦截器 compile 'com.squareup.okhttp3:logging-interceptor:3.9.0' //xrecyclerview依赖 compile 'com.jcodecraeer:xrecyclerview:1.3.2' //Glide依赖 compile 'com.github.bumptech.glide:glide:3.6.1' //eventbus依赖 compile 'org.greenrobot:eventbus:3.1.1' //Retrofit依赖 compile 'com.squareup.retrofit2:retrofit:2.0.2' compile 'com.squareup.retrofit2:converter-gson:2.0.2' // RxJava依赖 compile 'io.reactivex:rxandroid:1.0.1' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile 'io.reactivex:rxjava:1.0.14' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.7' compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' // RxAndroid依赖 compile 'io.reactivex:rxandroid:1.0.1' //fresco依赖 compile 'com.facebook.fresco:fresco:0.12.0' // 在 API < 14 上的机器支持 WebP 时,需要添加 compile 'com.facebook.fresco:animated-base-support:0.12.0' // 支持 GIF 动图,需要添加 compile 'com.facebook.fresco:animated-gif:0.12.0' // 支持 WebP (静态图+动图),需要添加 compile 'com.facebook.fresco:animated-webp:0.12.0' compile 'com.facebook.fresco:webpsupport:0.12.0' // 仅支持 WebP 静态图,需要添加 compile 'com.facebook.fresco:webpsupport:0.12.0'
原地址:https://blog.csdn.net/qq_38127722/article/details/78552209
-
搭建一个安卓App的框架
2021-01-03 20:37:13导入的依赖 toolbar.xml toolbar的作用是设置顶部的工具栏以及设置各菜单项的名称 container.xml container是各个项目跳转的容器,诸如FraMyCount.java的各个类都加载到container这个容器上,然后这个容器再安放... -
安卓图片加载框架
2017-03-27 11:32:55安卓开发要经常与图片打交到,所以简单了解了一下图片加载框架以及测试他们加载图片的性能,最终选定Glide(图片处理占内存更小) 1. a .Glide使用 android studio开发工具 在app build 下进行依赖 dependencies { ...安卓开发要经常与图片打交到,所以简单了解了一下图片加载框架以及测试他们加载图片的性能,最终选定Glide(图片处理占内存更小)
1.
a .Glide使用
android studio开发工具 在app build 下进行依赖
dependencies {
compile 'com.github.bumptech.glide:glide:3.5.2'
}
b.
Glide.with(context) .load(imgpath)//图片路径 .placeholder(R.mipmap.header)//占位图
.error(R.mipmap.error(加载错误后显示的图片)
.diskCacheStrategy(DiskCacheStrategy.ALL)(缓存所有的) .centerCrop()//图片过大显示部分(二选一) .fitCenter()//完整的显示在控件中(二选一) .into(viewHolder.scaleInfoShouye);(控件)
-
Android代码-一个简单的安卓快速开发框架
2019-08-06 06:31:04一个简单的Android项目基础框架,提供基于注解的资源注入和事件绑定,UI管理,UI log打印等功能,达到快速开发的目的 项目结构 文件和路径 功能 src java 源码文件 res resources 文件 libc 编解码所需的... -
安卓Butterknife依赖注入的使用
2017-07-30 10:18:541、安装ButterKnife框架 在线安装:点击File→Project Structure→Modules下对应的项目→Dependencies→右侧的加号→Library Dependency→输入ButterKnife搜索,点击下载com.jakewharton:butterknife:7.0.1 2、... -
安卓依赖注入(DI)框架Hilt-Dagger入门
2021-02-18 14:11:17此处引出两个概念:IoC容器、DI依赖注入,我们将对象的创建过程、销毁过程交给IoC容器(称为控制反转),在需要使用对象时由容器提供(称为注入),从而减少复杂系统的代码耦合,提高编程效率。 如果大家接触过... -
安卓图片加载框架Gilde的用法
2018-06-05 20:28:36转自:http://blog.csdn.net/guolin_blog/article/details/53759439gilde 依赖:compile 'com.github.bumptech.glide:glide:3.7.0' 加载图片只需要一行核心代码: Glide.with(this).load(URl).into(imageView);... -
安卓开发 第一篇 关于依赖注入框架dagger2的使用和理解
2016-04-14 22:31:52(这篇博客真是磨难重重啊,写到一半电脑蓝屏了,还好markdown编辑器保持了部分类容)最近开始重构项目,在重构项目中用到了依赖注入框架dagger2,发现它确实很方便,能大大加快我们编写代码的速度,同时也很方便... -
安卓:GSY框架
2019-10-26 10:30:01下载自己看一下,非常简单,在下面我只介绍一下简单的视频播放 github地址:https://github.com/CarGuo/GSYVideoPlayer 导入完整依赖://完整版引入 implementation 'com.shuyu:GSYVideoPlayer:7.1.1' main_sgp = ... -
关于安卓glide图片框架加载的图片转换成圆形圆角的思路
2017-09-19 09:38:38自己集成的依赖地址(github):github 这两天一直在用glide图片框架做demo,慢慢的感受到glide图片框架的强大,具体的我也不一一再说,相信你们如果能搜索出我这篇文章,也是对glide框架有一定的了解。下面... -
安卓图片加载框架Fresco
2018-06-06 15:10:51Fresco中文官网:https://www.fresco-cn.org/ Fresco是Facebook开发的一款开源框架 号称目前最强的Android图片加载库在内存方面表现的极为优秀 支持Android2.3及以后的版本 首先先上一组加载图片的代码,不加... -
安卓怎么搭建框架?
2019-09-18 09:33:20今天在我的石墨文档中看到以下内容的整理 2018.4.3号...View对Model的依赖,会导致View也包含了业务逻辑; Controller会变得很厚很复杂。 MVP Model-View-Presenter,MVC的一个演变模式,将Controller换成了Pres... -
安卓快速开发框架AndroidOne.zip
2019-07-18 07:50:07One框架分为两个项目,OneCore为核心工程,androidOne为演示项目,依赖oneCore One整个框架为MVC模式搭建,基于android framework为核心,集成Android世界中的主流技术选型 以...
-
2.4.5 rossrv
-
【教程】SpringCloud+Nacos+Feign+Gateway ( 七 ) Nacos-Gateway 网关 熔断降级(推荐)
-
RN中Kirchhoff型问题的无穷多个解的存在性和多重性结果
-
QCOM骁龙处理器开发技术说明书 - Linux Camera Debugging Guide.pdf
-
MySQL 设计基础(数据库概论、初探)
-
银行申请-源码
-
PWM控制舵机
-
慕课web前端架构师
-
2021年软考系统规划与管理师-上午历年真题解析视频课程
-
深入浅出Docker(三):Docker开源之路
-
QCOM骁龙处理器开发技术说明书 - Sectools- Debug Policy Tool.pdf
-
图片嵌套窗体,将图片加载为子窗体在父容器内
-
汇文双机安装(浪潮).doc
-
xxljob源码分析
-
SQL游标模板
-
Spark源码系列(五)分布式缓存
-
AMDOpenCL大学课程(5)
-
AMDOpenCL大学课程(1)
-
spyder无法打开
-
每日一题——求最大公约数