最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android模仿微信收藏文件的標(biāo)簽處理功能

 更新時(shí)間:2016年11月14日 16:19:55   作者:zhengdan66  
這篇文章主要介紹了android模仿微信收藏文件的標(biāo)簽處理功能的相關(guān)資料,也可以刪除已編輯菜單,需要的朋友可以參考下

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

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

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() 
}

點(diǎn)擊下載源碼

以上所述是小編給大家介紹的android模仿微信收藏文件的標(biāo)簽處理功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 詳解android特性之CoordinatorLayout用法探析實(shí)例

    詳解android特性之CoordinatorLayout用法探析實(shí)例

    本篇文章主要介紹了android特性之CoordinatorLayout用法探析實(shí)例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-02-02
  • Android自定義View原理(實(shí)戰(zhàn))

    Android自定義View原理(實(shí)戰(zhàn))

    這篇文章主要介紹了Android自定義View原理,由于Android系統(tǒng)內(nèi)置的View不滿足我們的業(yè)務(wù)需求,變產(chǎn)生了需要自定義View的原因,關(guān)于自定義詳情,需要的小伙伴可以參考下面文章具體詳情
    2022-05-05
  • Android自定義View實(shí)現(xiàn)漸變色進(jìn)度條

    Android自定義View實(shí)現(xiàn)漸變色進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)漸變色進(jìn)度條,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • arcgis android之定位功能的示例代碼

    arcgis android之定位功能的示例代碼

    這篇文章主要介紹了arcgis android之定位功能的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-04-04
  • Android Flutter實(shí)現(xiàn)點(diǎn)贊效果的示例代碼

    Android Flutter實(shí)現(xiàn)點(diǎn)贊效果的示例代碼

    點(diǎn)贊這個(gè)動(dòng)作不得不說在社交、短視頻等App中實(shí)在是太常見了。本文將利用Flutter制作出一個(gè)點(diǎn)贊動(dòng)畫效果,感興趣的小伙伴可以學(xué)習(xí)一下
    2022-04-04
  • Android線程實(shí)現(xiàn)圖片輪播

    Android線程實(shí)現(xiàn)圖片輪播

    這篇文章主要介紹了Android線程實(shí)現(xiàn)圖片輪播,初始化3秒更換一次圖片背景,輪換播放,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • 一款超酷的Android自定義加載控件

    一款超酷的Android自定義加載控件

    這篇文章主要為大家詳細(xì)介紹了一款超酷的Android自定義加載控件,具有一定的實(shí)用性和參考價(jià)值,感興趣的朋友可以參考一下
    2016-05-05
  • Android實(shí)現(xiàn)ImageView圖片縮放和拖動(dòng)

    Android實(shí)現(xiàn)ImageView圖片縮放和拖動(dòng)

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)ImageView圖片縮放和拖動(dòng)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • 2021最新Android筆試題總結(jié)美團(tuán)Android崗職能要求

    2021最新Android筆試題總結(jié)美團(tuán)Android崗職能要求

    這篇文章主要介紹了2021最新Android筆試題總結(jié)以及美團(tuán)Android崗職能要求,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-08
  • Android 自定義SurfaceView詳解

    Android 自定義SurfaceView詳解

    本文主要介紹Android SurfaceView自定義方法,這里對(duì)SurfaceView的基礎(chǔ)知識(shí)做了詳解,并附簡單的示例代碼,以便參考,有需要的小伙伴可以參考下
    2016-08-08

最新評(píng)論

工布江达县| 教育| 东山县| 保山市| 马龙县| 仪征市| 洪雅县| 峨山| 商丘市| 揭东县| 景宁| 万年县| 木里| 当涂县| 铜川市| 咸阳市| 德钦县| 壶关县| 福安市| 内黄县| 鲁甸县| 安达市| 武义县| 威海市| 贡嘎县| 龙里县| 红原县| 陕西省| 昌江| 隆安县| 佛学| 元朗区| 西充县| 东莞市| 东明县| 浦江县| 丹寨县| 漳平市| 会泽县| 革吉县| 灵璧县|