日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android手机微信收藏功能实现,Android模仿微信收藏文件的标签处理功能

發布時間:2025/3/8 Android 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android手机微信收藏功能实现,Android模仿微信收藏文件的标签处理功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

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

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模仿微信收藏文件的標簽處理功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

總結

以上是生活随笔為你收集整理的android手机微信收藏功能实现,Android模仿微信收藏文件的标签处理功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。