這篇文章給大家介紹怎么在android中使用View實(shí)現(xiàn)一個(gè)滑動(dòng)刪除效果,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

實(shí)現(xiàn)功能
1、可以向左滑動(dòng),右側(cè)出現(xiàn)刪除
2、向左滑動(dòng)如果刪除出現(xiàn)一大半,松手打開刪除,反之關(guān)閉刪除
3、應(yīng)用場(chǎng)景
微信消息的刪除功能
實(shí)現(xiàn)原理
1、外面是一個(gè)ListView
2、條目是一個(gè)自定義控件繼承ViewGroup
1)、左邊一個(gè)TextView,右側(cè)屏幕外也有一個(gè)TextView
2)、所以繼承ViewGroup
實(shí)現(xiàn)步驟
1、創(chuàng)建一個(gè)SlideDeleteView類
1).構(gòu)造方法要關(guān)聯(lián)
public class SlideDelete extends ViewGroup {
private View leftView;
private View rightView;
private ViewDragHelper helper;
//第一步關(guān)聯(lián)構(gòu)造方法
//第二步重寫onMeasure和onLViewayout測(cè)量子View和布局子View
public SlideDelete(Context context) {
this(context,null);
}
public SlideDelete(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public SlideDelete(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
helper = ViewDragHelper.create(this, callback);
}
}
本文題目:怎么在android中使用View實(shí)現(xiàn)一個(gè)滑動(dòng)刪除效果-創(chuàng)新互聯(lián)
URL地址:http://chinadenli.net/article24/hpoje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、網(wǎng)站營(yíng)銷、品牌網(wǎng)站制作、用戶體驗(yàn)、ChatGPT、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容