android手機微信收藏功能實現,Android模仿微信收藏文件的標簽處理功能

最近需要用到微信的標簽功能(如下圖所示)。該功能可以添加已有標簽,也可以自定義標簽。也可以刪除已編輯菜單。研究了一番。發現還是挺有意思的,模擬實現相關功能。

6d1581f67e0ba2819a1f00bf149463a6.png

4305daaf90d8c88e4fc779bb5bd57c3b.png

該功能使用類似FlowLayout的功能。Flowlayout為一個開源軟件(https://github.com/ApmeM/android-flowlayout),功能為自動換行的布局類型

3d03c936e6ba523b5c27c0161a3c37be.png

dca672cc4d3f5242bfd567b569659c79.png

import android.content.Context;

import android.util.AttributeSet;

import android.view.View;

import android.view.ViewGroup;

/**

*

* @author RAW

*/

public class FlowLayout extends ViewGroup {

private final static int PAD_H = 2, PAD_V = 2; // Space between child views.

private int mHeight;

public FlowLayout(Context context) {

super(context);

}

public FlowLayout(Context context, AttributeSet attrs) {

super(context, attrs);

}

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

assert (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED);

final int width = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();

int height = MeasureSpec.getSize(heightMeasureSpec) - getPaddingTop() - getPaddingBottom();

final int count = getChildCount();

int xpos = getPaddingLeft();

int ypos = getPaddingTop();

int childHeightMeasureSpec;

if(MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST)

childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);

else

childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

mHeight = 0;

for(int i = 0; i < count; i++) {

final View child = getChildAt(i);

if(child.getVisibility() != GONE) {

child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), childHeightMeasureSpec);

final int childw = child.getMeasuredWidth();

mHeight = Math.max(mHeight, child.getMeasuredHeight() + PAD_V);

if(xpos + childw > width) {

xpos = getPaddingLeft();

ypos += mHeight;

}

xpos += childw + PAD_H;

}

}

if(MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {

height = ypos + mHeight;

} else if(MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {

if(ypos + mHeight < height) {

height = ypos + mHeight;

}

}

height += 5; // Fudge to avoid clipping bottom of last row.

setMeasuredDimension(width, height);

} // end onMeasure()

@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

final int width = r - l;

int xpos = getPaddingLeft();

int ypos = getPaddingTop();

for(int i = 0; i < getChildCount(); i++) {

final View child = getChildAt(i);

if(child.getVisibility() != GONE) {

final int childw = child.getMeasuredWidth();

final int childh = child.getMeasuredHeight();

if(xpos + childw > width) {

xpos = getPaddingLeft();

ypos += mHeight;

}

child.layout(xpos, ypos, xpos + childw, ypos + childh);

xpos += childw + PAD_H;

}

}

} // end onLayout()

}

以上所述是小編給大家介紹的android模仿微信收藏文件的標簽處理功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/534750.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/534750.shtml
英文地址,請注明出處:http://en.pswp.cn/news/534750.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

strocli64 源碼_storcli 簡易使用介紹

MegaCli 是LSI公司官方提供的SCSI卡管理工具&#xff0c;由于LSI被收購變成了現在的Broadcom&#xff0c;所以現在想下載MegaCli&#xff0c;需要去Broadcom官網查找Legacy產品支持&#xff0c;搜索MegaRAID即可。關于MegaCli 的使用可以看我的另一篇博文&#xff0c;這里就不再…

android 電話號碼標記,強化電話標記功能 360手機衛士3.0安卓版體驗

作為“房產商”&#xff0c;上海仁恒置地集團營銷總監姚偉示通常每天也要接到20個左右房產或其他推銷電話。“現在已經形成了一個機械的對應方式&#xff0c;對于此類推銷電話&#xff0c;很多人包括我自己已經麻木了。”針對這種情況&#xff0c;360手機衛士發布了3.0.0正式版…

lua判斷字符不為空或空格_Lua判斷字符串前綴是否為指定字符的3種方法

在寫 lua debugger 的時候&#xff0c;我需要判斷一個字符串的前綴是不是 "" 。有三個方案&#xff1a;1.比較直觀的是 string.sub(str,1,1) ""2.感覺效率比較高的是 string.byte(str) 643.或者是 string.find(str,"") 1我推薦第三種。(注&am…

android 左滑按鈕,android開發類似微信列表向左滑動按鈕操作

話不多說&#xff0c;直接上代碼&#xff0c;有詳細的注釋的。layout布局中&#xff1a;主要是跟大家說一下listview怎么寫&#xff1a;android:id"id/pull_refresh_viewId"android:layout_width"match_parent"android:layout_height"match_parent&qu…

眼圖 非差分線_利用眼圖解決USB在布線中的信號完整性問題

EDA365歡迎您登錄&#xff01;您需要 登錄 才可以下載或查看&#xff0c;沒有帳號&#xff1f;注冊x本帖最后由 lifree 于 2020-2-5 14:37 編輯2 ]3 p D% B4 \ {/ n# V& |( A& p O通用串行總線USB (Universal Serial Bus)協議從1.0版本發展到現在&#xff0c;由于數據…

向量表示 運動拋物線_流動的美麗函數——拋物線淺談

事先說明&#xff1a;筆者初三&#xff0c;如在敘述中有不嚴謹的地方&#xff0c;還請諸位指出&#xff0c;自當感激不盡。&#xff08;本文默認受眾對象為初高中生&#xff0c;因此拋物線一律采取了yax的形式&#xff0c;高中的同學們可以應用旋轉矩陣把它變到y2px的形式QAQ筆…

android 獲取已安裝 錯誤代碼,android獲取手機已經安裝的app信息

Android獲取手機已安裝APP(系統/非系統)效果圖主體代碼private ListView mlistview;private ListpackageInfoList;private ListapplicationInfoList;private MyAdapter myAdapter;private PackageManager pm;Overrideprotected void onCreate(Bundle savedInstanceState) {supe…

android與ios ui切圖關系,APP-IOS與Android界面設計與切圖

做一全套的APP設計&#xff0c;流程是&#xff1a;1、界面設計&#xff1a;設計IOS界面&#xff1b;設計Android界面。2、切圖&#xff1a;切IOS的2倍圖和3倍圖&#xff1b;切Android的hdpi,xhdpi,xxhdpi這三個尺寸的圖。3、標注&#xff1a;以px為單位標注IOS界面的尺寸&#…

js禁止鼠標滑輪_js實現鼠標滑動到某個div禁止滾動

本文實例為大家分享了js實現鼠標滑動到某個div禁止滾動的具體代碼&#xff0c;供大家參考&#xff0c;具體內容如下項目中碰到一個場景就是當鼠標滑倒某個div的時候&#xff0c;滑動鼠標頁面不再滾動。這里主要是當鼠標滑動到該div時&#xff0c;監聽滾輪事件并通過preventDefa…

android app應用后臺休眠,安卓手機鎖屏后程序自動關閉,怎么設置手機app允許鎖屏后臺運行...

原標題&#xff1a;安卓手機鎖屏后程序自動關閉&#xff0c;怎么設置手機app允許鎖屏后臺運行安卓手機鎖屏后&#xff0c;很多程序就會自動關閉&#xff0c;實際上&#xff0c;這是安卓手機的一種保護機制。為了使系統能夠流暢穩定的運行以及更加省電&#xff0c;它都會在手機鎖…

ps怎么清屏_黑洞PS大賽刷屏!最后一張扎心了……

事件視界望遠鏡(EHT)項目組和中國科學院共同在上海天文臺發布由EHT“拍下”的人類歷史上首張黑洞照片這意味著人類成功獲得了超大黑洞的第一個直接視覺證據黑洞首次露出真容&#xff01;據說宇宙誕生了138億年年齡最大的黑洞也已經超過了100億歲經過了這么久黑洞家族的成員才終…

linux和windows和鴻蒙,linux很好,但為何大家都用Win,鴻蒙系統站錯陣營了嗎?

原標題&#xff1a;linux很好&#xff0c;但為何大家都用Win&#xff0c;鴻蒙系統站錯陣營了嗎&#xff1f;由目前已知信息可知&#xff0c;華為“鴻蒙系統”很可能基于linux開源程序搭建&#xff0c;這個特點與蘋果微軟由很大不同。蘋果手機目前主要使用Objective-C程序語言開…

centos7磁盤邏輯分區命令_CentOS7 磁盤分區(主分區、擴展分區和邏輯分區)的創建、掛載與刪除...

創建磁盤分區查看磁盤分區情況&#xff1a;fdisk -l[rootmodel ~]# fdisk -l //查看系統中所有磁盤的分區列表Disk/dev/sda: 107.4 GB, 107374182400 bytes, 209715200sectorsUnits sectors of 1 * 512 512bytesSector size (logical/physical): 512 bytes / 512bytesI/O size…

php使用webservivce_JWS服務開發使用指南

均支持該版本&#xff0c;主要你的web.xml文件中必須制定2.5版本xmlversion"1.0"encoding"UTF-8"?><web-appxmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xmlns"http://java.sun.com/xml/ns/javaee"xmlns:web"ht…

android sdk是灰的,Android Studio 2.3 sdk管理器標簽灰顯

Android Studio 2.3 - >配置 - > SDK管理器。 這些選項卡呈灰色顯示&#xff1a; SDK工具&#xff0c;SDK更新站點。此外&#xff0c;“Show Package Details”復選框呈灰色。 系統正常更新。沒有錯誤消息。Android Studio 2.3 sdk管理器標簽灰顯我認為這發生在Studio 2.…

android layer陰影,Android Layer-List實現自定義Shape陰影

一、給右側和底層加陰影android:left"2dp"android:top"2dp">android:angle"270"android:endColor"#0F000000"android:startColor"#0F000000" />android:bottomLeftRadius"6dip"android:bottomRightRadius&q…

localdatetime 默認時間_java中的時間與時區:LocalDateTime和Date

LocalDateTimeLocalDateTime本身不包含時區信息&#xff0c;它存儲的是年、月、日、時分秒&#xff0c;納秒這樣的數字。在不同的時區下&#xff0c;這樣的數字代表不同的時間。比如一個LocalDateTime存儲2020-01-01 08&#xff1a;00&#xff1a;00&#xff0c;這里省略納秒。…

html 拖拽坐標,Html+css實現拖拽導航條

div橫向拖拽排序body, div {padding: 0px;margin: 0px;}.box {position: relative;margin-left: 15px;padding: 10px;padding-right: 0px;width: 810px;border: blue solid 1px;}.box ul{list-style: none;overflow: hidden;padding: 0;margin:0;}.drag {float: left;border: #…

seata 如何開啟tcc事物_微服務分布式事務4種解決方案實戰

分布式事務分布式事務是指事務的參與者&#xff0c;支持事務的服務器&#xff0c;資源服務器分別位于分布式系統的不同節點之上&#xff0c;通常一個分布式事物中會涉及到對多個數據源或業務系統的操作。典型的分布式事務場景&#xff1a;跨銀行轉操作就涉及調用兩個異地銀行服…

python redis 哨兵_Redis哨兵機制

概述上篇文章主要說了Redis 復制的內容&#xff0c;但 Redis 復制有一個缺點&#xff0c;當主機 Master 宕機以后&#xff0c;我們需要人工解決切換&#xff0c;比如使用slaveof no one 。實際上主從復制并沒有實現&#xff0c;高可用&#xff0c; 高可用側重備份機器&#xff…