自定义 FlowLayout流式布局搜索框 加 GreenDao存取搜索记录,使用RecyclerView展示
输入框布局的shape
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"><corners android:radius="30dp"/><stroke android:width="2dp" android:color="@color/darkgray"/><solid android:color="@color/color_white"/><padding android:top="8dp" android:bottom="8dp" android:left="5dp"/> </shape>
热搜流式布局的shape
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <!-- <solid android:color="@android:color/white"/>--> <corners android:radius="28dp"/><stroke android:width="1dp" android:color="#3799f4"/><padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp" /> </shape>
自定义流式布局View的主体内容
import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List;/** * Created by Dewey . * 自定义流式布局显示搜索框 */ public class FlowLayout extends ViewGroup {public FlowLayout(Context context, AttributeSet attrs, int defStyle){super(context, attrs, defStyle);}public FlowLayout(Context context, AttributeSet attrs) {this(context, attrs, 0);}public FlowLayout(Context context) {this(context, null);}@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);int modeWidth = MeasureSpec.getMode(widthMeasureSpec);int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);int modeHeight = MeasureSpec.getMode(heightMeasureSpec);// 如果是warp_content情况下,记录宽和高 int width = 0;int height = 0;// 记录每一行的宽度与高度 int lineWidth = 0;int lineHeight = 0;// 得到内部元素的个数 int cCount = getChildCount();for (int i = 0; i < cCount; i++){// 通过索引拿到每一个子view View child = getChildAt(i);// 测量子View的宽和高,系统提供的measureChild measureChild(child, widthMeasureSpec, heightMeasureSpec);// 得到LayoutParams MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();// 子View占据的宽度 int childWidth = child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;// 子View占据的高度 int childHeight = child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;// 换行 判断 当前的宽度大于 开辟新行 if (lineWidth + childWidth > sizeWidth - getPaddingLeft() - getPaddingRight()){// 对比得到最大的宽度 width = Math.max(width, lineWidth);// 重置lineWidth lineWidth = childWidth;// 记录行高 height += lineHeight;lineHeight = childHeight;}else // 未换行 {// 叠加行宽 lineWidth += childWidth;// 得到当前行最大的高度 lineHeight = Math.max(lineHeight, childHeight);}// 特殊情况,最后一个控件 if (i == cCount - 1){width = Math.max(lineWidth, width);height += lineHeight;}}setMeasuredDimension(modeWidth == MeasureSpec.EXACTLY ? sizeWidth : width + getPaddingLeft() + getPaddingRight(),modeHeight == MeasureSpec.EXACTLY ? sizeHeight : height + getPaddingTop() + getPaddingBottom()// );}/** * 存储所有的View */ private List<List<View>> mAllViews = new ArrayList<List<View>>();/** * 每一行的高度 */ private List<Integer> mLineHeight = new ArrayList<Integer>();@Override protected void onLayout(boolean changed, int l, int t, int r, int b){mAllViews.clear();mLineHeight.clear();// 当前ViewGroup的宽度 int width = getWidth();int lineWidth = 0;int lineHeight = 0;// 存放每一行的子view List<View> lineViews = new ArrayList<View>();int cCount = getChildCount();for (int i = 0; i < cCount; i++){View child = getChildAt(i);MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();int childWidth = child.getMeasuredWidth();int childHeight = child.getMeasuredHeight();// 如果需要换行 if (childWidth + lineWidth + lp.leftMargin + lp.rightMargin > width - getPaddingLeft() - getPaddingRight()){// 记录LineHeight mLineHeight.add(lineHeight);// 记录当前行的Views mAllViews.add(lineViews);// 重置我们的行宽和行高 lineWidth = 0;lineHeight = childHeight + lp.topMargin + lp.bottomMargin;// 重置我们的View集合 lineViews = new ArrayList<View>();}lineWidth += childWidth + lp.leftMargin + lp.rightMargin;lineHeight = Math.max(lineHeight, childHeight + lp.topMargin+ lp.bottomMargin);lineViews.add(child);}// for end // 处理最后一行 mLineHeight.add(lineHeight);mAllViews.add(lineViews);// 设置子View的位置 int left = getPaddingLeft();int top = getPaddingTop();// 行数 int lineNum = mAllViews.size();for (int i = 0; i < lineNum; i++){// 当前行的所有的View lineViews = mAllViews.get(i);lineHeight = mLineHeight.get(i);for (int j = 0; j < lineViews.size(); j++){View child = lineViews.get(j);// 判断child的状态 if (child.getVisibility() == View.GONE){continue;}MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();int lc = left + lp.leftMargin;int tc = top + lp.topMargin;int rc = lc + child.getMeasuredWidth();int bc = tc + child.getMeasuredHeight();// 为子View进行布局 child.layout(lc, tc, rc, bc);left += child.getMeasuredWidth() + lp.leftMargin+ lp.rightMargin;}left = getPaddingLeft();top += lineHeight;}}/** * 与当前ViewGroup对应的LayoutParams */ @Overridepublic LayoutParams generateLayoutParams(AttributeSet attrs){return new MarginLayoutParams(getContext(), attrs);}}
主MainActivity布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" ><LinearLayout android:layout_marginTop="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" ><ImageView android:layout_gravity="center_vertical" android:layout_marginLeft="8dp" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/left" android:id="@+id/backJian" /><LinearLayout android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" ><EditText android:id="@+id/edit_input" android:layout_gravity="center_vertical" android:layout_margin="10dp" android:drawableLeft="@drawable/search_icon" android:drawablePadding="5dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/search_edittext_shape" android:textSize="16sp" android:imeOptions="actionSearch" android:inputType="text" android:hint="请输入关键字"/></LinearLayout><ImageView android:src="@drawable/right" android:id="@+id/search_btn" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:layout_gravity="center_vertical" android:layout_width="50dp" android:layout_height="50dp"/></LinearLayout><TextView android:layout_width="match_parent" android:layout_marginTop="10dp" android:layout_height="1dp" android:background="#050505" /><!-- 流式布局 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:textStyle="bold" android:textSize="18sp" android:text="热搜" /><!--自定义的flowlayout,引用的是自己的包名--> <com.example.custom.FlowLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:id="@+id/id_flowlayout" ></com.example.custom.FlowLayout><TextView android:layout_width="match_parent" android:layout_marginTop="10dp" android:layout_height="1dp" android:background="#050505" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:textStyle="bold" android:textSize="18sp" android:text="搜索记录" /><android.support.v7.widget.RecyclerView android:id="@+id/history_recyclerView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10dp"></android.support.v7.widget.RecyclerView><Button android:layout_width="match_parent" android:layout_marginRight="60dp" android:layout_marginLeft="60dp" android:layout_height="40dp" android:background="#ffffff" android:text="清空历史搜索" android:id="@+id/clearbtn"/></LinearLayout>
主 MainActivity功能代码
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import org.greenrobot.greendao.query.Query; import java.util.ArrayList; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;/* 搜索框页面: 1. 搜索框输入内容 2. 自定义流式布局,展示搜索的菜名记录 3. 使用GreenDao操作数据库,保存搜索记录,当下次进入搜索页面,能展示记录 4. 点击清除按钮清除数据库内容 5. 点击搜索,根据搜索内容,请求数据 */ public class MainActivity extends Activity {@BindView(R.id.edit_input)EditText editInput;@BindView(R.id.search_btn)ImageView searchBtn;@BindView(R.id.history_recyclerView)RecyclerView historyRecyclerView;@BindView(R.id.id_flowlayout)FlowLayout flowlayout;private HistoryAdapter historyAdapter;List<String> list = new ArrayList<>(); //历史搜索输入数据集合 private Query<SearchDaoBean> queryDao; //历史搜索查询数据集合 private SearchDaoBeanDao dao;private String flows[] = {"应急启动电源", "餐桌", "粽子散装","智能手表", "摩托车配件", "批发方便面","王中王火腿", "手机", "桶装矿泉水","U盘64G", "机械革命电脑", "洗发水","护发素", "奶粉", "search", "logcat" };@Override protected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ButterKnife.bind(this);//自定义流式布局初始化视图 initChildViews();//设置搜索记录布局视图 initHistoryResultData();//获取数据库实例,把历史记录显示在页面上 dao = MyApplication.session.getSearchDaoBeanDao();queryDao = dao.queryBuilder().orderAsc(SearchDaoBeanDao.Properties.Id).build();List<SearchDaoBean> daoBeanList = queryList();for (int i = 0; i < daoBeanList.size(); i++) {list.add(daoBeanList.get(i).getSelectGoods());}}//流式布局 public void initChildViews() {ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);//下面为 热搜流式布局子条目间距 lp.leftMargin = 10;lp.rightMargin = 10;lp.topMargin = 10;lp.bottomMargin = 10;for(int i = 0; i < flows.length; i ++){TextView view = new TextView(this);view.setText(flows[i]);view.setTextSize(21);//view.setTextColor(Color.WHITE); view.setBackgroundDrawable(getResources().getDrawable(R.drawable.label_bg));//添加到父View flowlayout.addView(view,lp);}}private void initHistoryResultData() {//设置搜索结果适配器以及布局管理器 historyRecyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false));historyAdapter = new HistoryAdapter(MainActivity.this, list);historyRecyclerView.setAdapter(historyAdapter);}@OnClick({R.id.search_btn, R.id.clearbtn , R.id.backJian})public void onViewClicked(View view) {switch (view.getId()) {//点击搜索按钮,传递数据RecyclerView显示,并存入数据库 case R.id.search_btn://判断输入为空情况下 String string = editInput.getText().toString().trim();if (TextUtils.isEmpty(string) || string.length() == 0) {Toast.makeText(this, "输入内容不能为空", Toast.LENGTH_SHORT).show();return;}//保存搜索历史到数据库 String trim = editInput.getText().toString().trim();SearchDaoBean daoBean = new SearchDaoBean(null, "1775", "TheScar", trim);dao.insert(daoBean);historyAdapter.notifyDataSetChanged();break;//清空历史搜索集合,,清空数据库,刷新数据 case R.id.clearbtn:list.clear();deleteAllData();historyAdapter.notifyDataSetChanged();break;//销毁当前页面 case R.id.backJian:finish();break;default:break;}}//查询全部数据的方法 private List<SearchDaoBean> queryList() {List<SearchDaoBean> daoBeans = queryDao.list();return daoBeans;}//删除所有数据,即清空历史记录 public void deleteAllData() {dao.deleteAll();} }
历史搜索记录布局适配器 HistoryAdapter
import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.duhongwang20180601.R; import java.util.List;/** * 历史搜索记录数据 适配器 */ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHolder>{private Context context;private List<String> list;public HistoryAdapter(Context context, List<String> list) {this.context = context;this.list = list;}@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {View view = View.inflate(context, R.layout.layout_history, null);ViewHolder holder = new ViewHolder(view);return holder;}@Override public void onBindViewHolder(ViewHolder holder, int position) {holder.tv.setText(list.get(position));}@Override public int getItemCount() {return list.size();}public class ViewHolder extends RecyclerView.ViewHolder {private TextView tv;public ViewHolder(View itemView) {super(itemView);tv = (TextView)itemView.findViewById(R.id.history_text);}} }
适配器对应的布局 layout_history.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/history_text" android:layout_margin="7dp" android:textSize="15sp" android:text="" /></LinearLayout>
GreenDao全局配置初始化 MyApplication
import android.app.Application; import com.example.duhongwang20180601.dao.DaoMaster; import com.example.duhongwang20180601.dao.DaoSession; import com.facebook.drawee.backends.pipeline.Fresco; import org.greenrobot.greendao.database.Database;/** * Fresco GreenDao 的初始化全局配置类 */ public class MyApplication extends Application {//抽取为全局变量 public static DaoSession session;@Override public void onCreate() {super.onCreate();//1. Fresco Fresco.initialize(this);//2. GreenDao DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "rikao");Database db = helper.getWritableDb();session = new DaoMaster(db).newSession();} }
搜索框输入数据封装为 GreenDao bean 类
import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Generated;/** * Created by Dewey . * 搜索框输入数据封装为 DreenDao bean 类 */ @Entity public class SearchDaoBean {@Id(autoincrement = true)private Long id;private String uid;private String uname;private String selectGoods;@Generated(hash = 1024397953)public SearchDaoBean(Long id, String uid, String uname, String selectGoods) {this.id = id;this.uid = uid;this.uname = uname;this.selectGoods = selectGoods;}@Generated(hash = 1406499419)public SearchDaoBean() {}public Long getId() {return this.id;}public void setId(Long id) {this.id = id;}public String getUid() {return this.uid;}public void setUid(String uid) {this.uid = uid;}public String getUname() {return this.uname;}public void setUname(String uname) {this.uname = uname;}public String getSelectGoods() {return this.selectGoods;}public void setSelectGoods(String selectGoods) {this.selectGoods = selectGoods;}}
布局用到的图片
left.png
right.png
search_icon.png
功能依赖
//1. Recycycleview compile 'com.android.support:recyclerview-v7:26.+'
//2.添加GreenDao及数据库database的依赖 compile 'org.greenrobot:greendao:3.2.2' compile 'org.greenrobot:greendao-generator:3.0.0' compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar' //数据库加密(较新版本)
//7.ButtonKnife //butterknife在Studio3.0版本上需使用以下8.8.1版本(下面2行代码都要加) compile 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
本文章到此结束,如有见解,请指出。
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
搜索框布局+流式布局代码
背景圆角(shape_back) xml version="1.0" encoding="utf-8"?> shape xmlns:android="http://schemas.android.co...
shilei_comeon
2018-01-03 13:02:25
阅读数:86
android搜索热词(热门标签)流式布局的实现
先看下效果图1、流式布局实现继承ViewGroup,重写onMeasure,onLayout方法。代码如下:package com.example.lin.flowlayoutdemo;import ...
zhoulin541
2016-07-13 14:32:32
阅读数:2828
搜索框布局+流式布局代码 - shilei_comeon的博客 - CSDN博客
android:layout_height="wrap_content" android:text="搜索" /> </Linear...android:background="#AAAAAA" /> //流式布局 <TextView android:layout_...
2018-1-3
首先流式布局搜索框 - CSDN博客
首先流式布局搜索框2018年05月31日 08:57:01 阅读数:1 依赖 implementation ...rxandroid:2.0.1' implementation 'com.squareup.retrofit2:retrofit:2.1.0' ...
2018-5-31
Android 热门搜索,自定义流式布局,自动换行,自动补齐
二话不说,先上图,如果是你们苦苦寻找的效果,请接着往下看。 绝对干货,直接上代码,直接讲用法,不讲原理,不讲思路,不绕弯弯,就是这么实在!就是喜欢你们复制粘贴! 想要知道如何实现的,代码里面的...
hzlxtq123
2016-12-22 14:51:09
阅读数:632
Android搜索框存储搜索记录 - CSDN博客
越来越多的App都用到了搜索框,公司的项目也用到了搜索框,还提出来以下需求:输入...Android 流式布局 + 搜索记录,包括多数据本地存储 转载地址为:http://www....
2018-5-25
FlowLayout流式布局实现搜索清空历史记录 - CSDN博客
效果图:点击搜索框将搜索的历史在流式布局中展示出来,清空历史记录就会将历史清空...<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
2018-5-18
Android自定义流式布局/自动换行布局
Android自定义流式布局/自动换行布局 最近,Google开源了一个流式排版库“FlexboxLayout”,功能强大,支持多种排版方式,如各种方向的自动换行等,具体资料各位可搜索学习^_^。 ...
zengd0
2016-08-14 23:21:04
阅读数:2480
Android 流式布局之自动换行
import android.content.Context; import android.util.AttributeSet; import android.view.View; import a...
yeyuewushang
2017-07-14 11:02:02
阅读数:721
Android 仿快播搜索框上方悬浮的文字搜索
仿快播搜索框页面悬浮的搜索关键字漂浮、飞入飞出的效果 综合评分:4 收藏(4)...android 流添加 热门搜索,切换历史与热门 上传资源 uuid12345 关注 积分97 ...
2018-5-8
自定义view+流式布局+greendao历史搜索 - CSDN博客
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="...FlowLayout流式布局实现搜索清空历史记录 效果图:点击搜索框将搜索的历史在流式...
2018-5-30
Android学习笔记:自定义实现流式布局
前几天在开发项目的时候,有一个需求是展示历史搜索启示 ,展示的样式是像瀑布流一样(每一行展示的控件个数根据控件的内容不同而不相同,当一行展示满后,自动换行展示)。最开始是自定义LinearLayout...
true100
2015-12-29 11:09:31
阅读数:2054
搜索框历史记录,流式布局 - CSDN博客
搜索框历史记录,流式布局2018年05月02日 09:46:51 阅读数:2 public class ...<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" andr...
2018-5-2
Android中关键词的流式布局 - CSDN博客
项目的开发过程中,用到了如上图所示的流式布局,在一番查找之后,在一叶飘舟大神博客的基础上,进行了一些编写,由于之前基本没有使用过自定义的控件,所以属于边敲...
2018-5-22
自定义流式布局实现搜索历史
public class FlowLayout extends ViewGroup{ public FlowLayout(Context context, AttributeSet attr...
qq_41161483
2018-05-28 16:53:25
阅读数:40
Android自定义ViewGroup实现流式布局
实现宽度不足自动换行的流式布局: FlowLayout.java package com.jackie.flowlayout; import android.content.Context; imp...
shineflowers
2015-08-28 18:02:44
阅读数:2166
Android搜索控件简介
Android 搜索框:SearchView 的属性和用法详解 Android之搜索功能的实现 Android搜索控件SearchView的用法 Android自定义控件(打造流布局实现热门搜索标签) 立即下载...
2018-5-4
undefined
自定义view实现流式布局
显示效果如下,自定义view,重写onMeasure方法,测量wrap_content模式下控件的宽高,重写onLayout的方法,布局里面的子view,支持paddign属性.其实整个逻辑并不复杂,...
lulalei
2017-07-25 14:08:50
阅读数:170
搜索历史记录流式布局展示
Config package com.tan.searchhistory.constants; public class Config { //数据库 public sta...
legend12300
2018-01-11 14:03:09
阅读数:176
百度地图自定义搜索框控件,并添加事件
function CreateControl() { function ZoomControl() { // 设置默认停靠位置和偏移量 ...
two_people
2016-11-27 16:32:51
阅读数:3003
流式布局FlowLayout以及动态添加Item的实现
http://blog.csdn.net/lmj623565791/article/details/38352503 ,本文出自【张鸿洋的博客】 1、概述 上一篇已经基本给大家介绍了如何自定义Vi...
qq_34247200
2017-04-01 15:39:26
阅读数:1059
Android自定义控件之流式布局
脑筋急转: 在一个房间里,有油灯 ,暖炉及壁炉。现在,想要用一根火柴将三个器具点燃,请问首先应该点燃哪一个? 请查看文章最后有有解析...
zl18603543572
2016-03-12 22:28:13
阅读数:2231
【Android】掌握自定义LayoutManager(二) 实现流式布局
转载请标明出处: http://blog.csdn.net/zxt0601/article/details/52956504 本文出自:【张旭童的博客】 本系列文章相关代码传送门: 自...
zxt0601
2016-10-28 17:58:17
阅读数:17266
Android自定义控件--流式布局(FlowLayout)--自动适配
在android开发中,随着开发需求的不断提升,android原生的控件在很大程度上已不能满足开发者以及用户的需求,为了更好的增加用户体验,更有利的维护UI,在一个完整的程序中,自定义控件往往是不可或...
MyLoveyaqiong
2016-11-03 01:37:59
阅读数:4193
Android仿天猫搜索历史记录显示自定义布局
这两天都在弄搜索界面,网上查看了下,参考了下面这位兄弟的: https://www.oschina.net/question/54100_32893 顺便把图也搬了 这个有个缺点,就是必须全屏,...
ming6365630
2017-07-26 10:35:53
阅读数:1298
Android中的自定义View(二)之 流式布局实现
我们在上一篇文章《Android中的自定义View》中介绍过自定义View的几种方式,并通过示例一演示了“直接继承View”的自定义View的使用情况。今天接着来介绍自定义View里稍为复杂的“直接继...
lyz_zyx
2017-10-10 11:52:09
阅读数:286
Android自定义View实现流式布局TextView
2016年12月30日 18KB 下载
流式按钮布局-热门搜索-历史搜索
App搜索页面经常用到关键词提示,例如手机淘宝的【历史搜索】,网易云音乐的【热门搜索】。为了方便使用,我写了一个可以流式布局按钮的view并封装。【文末附运行效果及demo】思考1.需要哪些样式? 按...
RachalZhou
2016-11-24 19:37:17
阅读数:160
在导航栏上添加搜索框的问题
自定义一个搜索框添加到导航栏上, _searchBar = [[ZJBSearchBar alloc]initWithFrame:CGRectMake(7,6, screenSize.wi...
qq_35340833
2016-07-11 11:09:21
阅读数:282
个人资料
wrpbk
- 原创
- 34
- 粉丝
- 4
- 喜欢
- 0
- 评论
- 0
- 等级:
- 访问:
- 1351
- 积分:
- 342
- 排名:
- 23万+
自定义 FlowLayout流式布局搜索框 加 GreenDao存取搜索记录,使用RecyclerView展示相关推荐
- Android FlowLayout 流式布局
FlowLayout 流式布局 Android 流式布局控件,实现自动换行,操出范围可以滑动功能,未使用控件复用功能,所以不应该有太多的子控件. 主要包含功能: 流式布局,自动换行 使用Adapter ...
- android 搜索历史流布局,FlowLayout流式布局实现搜索清空历史记录
本文实例为大家分享了FlowLayout实现搜索清空历史记录的具体代码,供大家参考,具体内容如下 效果图:点击搜索框将搜索的历史在流式布局中展示出来,清空历史记录就会将历史清空,每次搜索后都存入sp中 ...
- FlowLayout流式布局实现搜索清空历史记录
效果图:点击搜索框将搜索的历史在流式布局中展示出来,清空历史记录就会将历史清空,每次搜索后都存入sp中,每次进入页面都先判断sp里是否有值并展示 首先需要导入一个module,下载地址:https:/ ...
- Android FlowLayout流式布局
最近使用APP的时候经常看到有 这种流式布局 ,今天我就跟大家一起来动手撸一个这种自定义控件. 首先说一下自定义控件的流程: 自定义控件一般要么继承View要么继承ViewGroup View的自定义 ...
- Flowlayout流式布局使用(轻量级)
Flowlayout属于自定义流式布局,意思就是说从左上角开始添加原件,依次往后排,第一行挤满了就换一行接着排. 本文所使用的FlowLayout来自于鸿洋大神的框架. 只取了一个自定义控件,没有鸿洋 ...
- 4.布局:FlowLayout流式布局(Java swing 入门)
FlowLayout(流式布局管理器)是 JPanel 和 JApplet 的默认布局管理器.FlowLayout 会将组件按照从上到下.从左到右的放置规律逐行进行定位.与其他布局管理器不同的是,Fl ...
- 100行Android代码自定义一个流式布局-FlowLayout
首先来看一下 手淘HD - 商品详情 - 选择商品属性 页面的UI 商品有很多尺码,而且展现每个尺码所需要的View的大小也不同(主要是宽度),所以在从服务器端拉到数据之前,展现所有尺码所需要的行数和 ...
- 流式布局实现热搜和历史搜索
最近项目中在做热搜和历史搜索记录,开始是将横屏平均分成三份进行显示,后来需求说像个豆腐块,太难看了,要求是按着搜索输入的字的多少进行显示,就想天猫APP历史搜索那样的效果进行显示,其实这样的效果不用我 ...
- FlowLayout 流式布局加点击事件
//简单优化之后的 public class FlowLayout extends ViewGroup {private Context con;private View child;private ...
最新文章
- APL开发日志--2012-11-26
- oracle的adr,oracle ADR
- Android官方培训课程中文版
- Android中使用Canvas和Paint绘制一个安卓机器人
- 偶尔用得上的MySQL操作
- CG-CTF-Web-单身二十年
- SAP Spartacus读取User Address的action是如何被Effect接收的
- SAP云平台CloudFoundry环境试用帐号过期了怎么办
- 浅谈K短路算法(KSP)之一(A*算法求解)
- 编译 Linux2.6 内核总结【ZT】
- mysql基线检查_Mysql安全基线检查
- HDU1850 Being a Good Boy in Spring Festival【Nim博弈】
- 又丢脸了,“要源码上门自取”,结果美女真上门了!国内企业再惹争议
- 用友U8案例教程委外管理前台操作
- 召唤神龙Ladon强化Cobalt Strike
- 将war文件解压到指定目录
- matlab 2018 adams,关于ADAMS与MATLAB联合仿真的一点经验
- 编程入门——计算机硬件介绍
- Qt开发——图片缩放简述
- 计算机基础笔记(摘录)
热门文章
- 攻克苹果2.1被拒问题 韩俊强的博客
- 【每日一题】打卡 18
- 2020年中国高压变频器行业现状分析,变频用变压器具有较大的增长空间及快速发展潜力「图」
- matlab 图片RGB颜色提取(第二版)
- Android模仿新浪微博(主页微博,评论界面)
- 对微型计算机工作影响最小的因数是,高功率因数变流器起到什么作用?
- “新能源+储能“从数字孪生开始,图扑将智慧电力做到极致
- JSR303校验前端传递的数据
- 计算机二级上机指导是什么,计算机等级考试与上机指导
- c语言 试题 中荷,2017年东北大学中荷生物医学与信息工程学院842计算机专业基础考研强化模拟题...