亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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)功能。

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

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ì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android中WebView的基本配置與填坑記錄大全

    Android中WebView的基本配置與填坑記錄大全

    webview是一直都很痛恨的控件,你又不能不用,但是一旦大規(guī)模測(cè)試起來(lái)你就發(fā)現(xiàn)這個(gè)webview真是坑。各種你想不到的錯(cuò)誤 在各種奇怪的手機(jī),各種不一樣的版本里出現(xiàn)各種想不到的問(wèn)題。本文就介紹了Android中WebView的基本配置與遇到的一些填坑記錄,需要的朋友可以參考下。
    2017-11-11
  • Android自定義WaveView實(shí)現(xiàn)波浪進(jìn)度效果

    Android自定義WaveView實(shí)現(xiàn)波浪進(jìn)度效果

    最近注意到百度外賣(mài)以及淘寶個(gè)人中心,都用到了類(lèi)似水波起伏的效果,于是就參照網(wǎng)上的資料然后自己整改,自定義了一個(gè)waveView來(lái)實(shí)現(xiàn)這個(gè)效果,文中給出來(lái)詳細(xì)的實(shí)現(xiàn)原理及實(shí)例代碼,有需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。
    2017-01-01
  • 詳解android shape的使用總結(jié)

    詳解android shape的使用總結(jié)

    在Android程序開(kāi)發(fā)中,我們經(jīng)常會(huì)去用到Shape這個(gè)東西去定義各種各樣的形狀,本篇文章主要介紹了android shape的使用,有興趣的可以一起了解一下。
    2016-12-12
  • Android控件陰影顏色調(diào)整示例

    Android控件陰影顏色調(diào)整示例

    這篇文章主要介紹了Android控件陰影顏色調(diào)整示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • Android繪制跟隨手指移動(dòng)的小球

    Android繪制跟隨手指移動(dòng)的小球

    這篇文章主要為大家詳細(xì)介紹了Android繪制跟隨手指移動(dòng)的小球,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法

    Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法

    這篇文章主要給大家介紹了關(guān)于在Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧
    2018-05-05
  • Android模擬美團(tuán)客戶(hù)端進(jìn)度提示框

    Android模擬美團(tuán)客戶(hù)端進(jìn)度提示框

    這篇文章主要為大家詳細(xì)介紹了Android模擬美團(tuán)客戶(hù)端進(jìn)度提示框的實(shí)現(xiàn)過(guò)程,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2015-09-09
  • Android側(cè)滑菜單控件DrawerLayout使用詳解

    Android側(cè)滑菜單控件DrawerLayout使用詳解

    這篇文章主要為大家詳細(xì)介紹了Android側(cè)滑菜單控件DrawerLayout的使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • 解析Android中string-array數(shù)據(jù)源的簡(jiǎn)單使用

    解析Android中string-array數(shù)據(jù)源的簡(jiǎn)單使用

    本篇文章是對(duì)Android中string-array數(shù)據(jù)源的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • Android 滑動(dòng)定位和吸附懸停效果實(shí)現(xiàn)代碼

    Android 滑動(dòng)定位和吸附懸停效果實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android 滑動(dòng)定位和吸附懸停效果實(shí)現(xiàn)代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08

最新評(píng)論