伴随ListView、RecyclerView、ScrollView滚动滑入滑出小图标--第三方开源--FloatingActionButton
来源:互联网 发布:阿里巴巴外贸绑定域名 编辑:程序博客网 时间:2024/06/10 21:41
FloatingActionButton在github上的项目主页是:https://github.com/makovkastar/FloatingActionButton
它的依赖包NineOldAndroids在github上的项目主页是:https://github.com/JakeWharton/NineOldAndroids
(导包的时候注意要把android-support-v7-appcompat作为它的一个Library,不要重复了NineOldAndroids的引用)
测试代码:
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.zzw.testfloatingactionbutton.MainActivity" > <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent" /> <com.melnykov.fab.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_margin="16dip" android:src="@drawable/ic_launcher" fab:fab_shadow="true" fab:fab_type="normal" /></RelativeLayout>
MainActivity.java:
package com.zzw.testfloatingactionbutton;import com.melnykov.fab.FloatingActionButton;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.ArrayAdapter;import android.widget.ListView;import android.widget.Toast;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] data=new String[100]; for(int i=0;i<data.length;i++){ data[i]="ZZW1994"+i; } ListView listView=(ListView) findViewById(R.id.listView); ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,data); listView.setAdapter(adapter); //附着在ListView,跟随ListView滚动滑入滑出 FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToListView(listView); fab.setColorPressed(0xffb71c1c); fab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(), "hello", 0).show(); } }); }}
0 0
- 伴随ListView、RecyclerView、ScrollView滚动滑入滑出小图标--第三方开源--FloatingActionButton
- Android第三方FloatingActionButton:伴随ListView、RecyclerView、ScrollView滚动滑入滑出
- Android滚动截屏,ScrollView截屏,Listview截屏,Recyclerview截屏
- Android滚动截屏,ScrollView截屏,Listview截屏,Recyclerview截屏
- ScrollView里面嵌套ListView,RecyclerView
- ScrollView嵌套ListView,RecyclerView问题
- listView 和scrollView滚动位置
- Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【1】
- Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【2】
- Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton): FloatingActionsMenu【3】
- ListView 实现类似listview + scrollview滚动效果
- scrollview嵌套listview,listview不滚动问题
- Android长截屏-- ScrollView,ListView及RecyclerView截屏
- ListView,ScrollView,RecyclerView上下滑动监听
- ScrollView嵌套Listview/RecyclerView内容显示不全
- ScrollView与ListView RecyclerView的嵌套
- ScrollView嵌套Listview,scrollview总是滚动到listview的位置
- ScrollView、RecyclerView、ScrollView嵌套ListView性能优化方案
- Java微博爬虫的学习
- VS2008 ClickOnce发布Xenocode混淆的应用
- iOS系统UITextField研究
- Unity+NGUI性能优化方法总结
- linux和windows下的“回车符”和“换行符”
- 伴随ListView、RecyclerView、ScrollView滚动滑入滑出小图标--第三方开源--FloatingActionButton
- Discuz!X2.5 在FastCGI模式下php-cgi.exe进程数量增多的原因分析
- has a / is a 的区别
- TortoiseSVN版本控制软件的Windows安装与应用
- Android Native/Tombstone Crash Log 详细分析
- Android Studio更新错误 Connection failed. Please check your network connection and try again
- Android数据库-开源LitePal (二)
- jquery图片轮播
- 低版本的VS2008打开高版本VS2010