第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

求源碼。。。

show()、hide()、getSectionsByPoint(ev.getY())、cantains(float x, float y)這四個方法呢? 老師,你這懸念留的也是醉了...能不能靠譜點 還是極客學院靠譜點,手敲+源碼.....

正在回答

2 回答


【蜘蛛俠TG@abin789】-5601
【蜘蛛俠TG@abin789】-5602
【蜘蛛俠TG@abin789】-5603
【蜘蛛俠TG@abin789】-5604
【蜘蛛俠TG@abin789】-5605
【蜘蛛俠TG@abin789】-5606
【蜘蛛俠TG@abin789】-5607
【蜘蛛俠TG@abin789】-5608
【蜘蛛俠TG@abin789】-5609
【蜘蛛俠TG@abin789】-5610
【蜘蛛俠TG@abin789】-5611
【蜘蛛俠TG@abin789】-5612
【蜘蛛俠TG@abin789】-5613
【蜘蛛俠TG@abin789】-5614
【蜘蛛俠TG@abin789】-5615
【蜘蛛俠TG@abin789】-5616
【蜘蛛俠TG@abin789】-5617
【蜘蛛俠TG@abin789】-5618
【蜘蛛俠TG@abin789】-5619
【蜘蛛俠TG@abin789】-5620
【蜘蛛俠TG@abin789】-5621
【蜘蛛俠TG@abin789】-5622
【蜘蛛俠TG@abin789】-5623
【蜘蛛俠TG@abin789】-5624
【蜘蛛俠TG@abin789】-5625
【蜘蛛俠TG@abin789】-5626
【蜘蛛俠TG@abin789】-5627
【蜘蛛俠TG@abin789】-5628
【蜘蛛俠TG@abin789】-5629
【蜘蛛俠TG@abin789】-5630
【蜘蛛俠TG@abin789】-5631
【蜘蛛俠TG@abin789】-5632
【蜘蛛俠TG@abin789】-5633
【蜘蛛俠TG@abin789】-5634
【蜘蛛俠TG@abin789】-5635
【蜘蛛俠TG@abin789】-5636
【蜘蛛俠TG@abin789】-5637
【蜘蛛俠TG@abin789】-5638
【蜘蛛俠TG@abin789】-5639
【蜘蛛俠TG@abin789】-5640
【蜘蛛俠TG@abin789】-5641
【蜘蛛俠TG@abin789】-5642
【蜘蛛俠TG@abin789】-5643
【蜘蛛俠TG@abin789】-5644
【蜘蛛俠TG@abin789】-5645
【蜘蛛俠TG@abin789】-5646
【蜘蛛俠TG@abin789】-5647
【蜘蛛俠TG@abin789】-5648
【蜘蛛俠TG@abin789】-5649
【蜘蛛俠TG@abin789】-5650
【蜘蛛俠TG@abin789】-5651
【蜘蛛俠TG@abin789】-5652
【蜘蛛俠TG@abin789】-5653
【蜘蛛俠TG@abin789】-5654
【蜘蛛俠TG@abin789】-5655
【蜘蛛俠TG@abin789】-5656
【蜘蛛俠TG@abin789】-5657
【蜘蛛俠TG@abin789】-5658
【蜘蛛俠TG@abin789】-5659
【蜘蛛俠TG@abin789】-5660
【蜘蛛俠TG@abin789】-5661
【蜘蛛俠TG@abin789】-5662
【蜘蛛俠TG@abin789】-5663
【蜘蛛俠TG@abin789】-5664
【蜘蛛俠TG@abin789】-5665
【蜘蛛俠TG@abin789】-5666
【蜘蛛俠TG@abin789】-5667
【蜘蛛俠TG@abin789】-5668
【蜘蛛俠TG@abin789】-5669
【蜘蛛俠TG@abin789】-5670
【蜘蛛俠TG@abin789】-5671
【蜘蛛俠TG@abin789】-5672
【蜘蛛俠TG@abin789】-5673
【蜘蛛俠TG@abin789】-5674
【蜘蛛俠TG@abin789】-5675
【蜘蛛俠TG@abin789】-5676
【蜘蛛俠TG@abin789】-5677
【蜘蛛俠TG@abin789】-5678
【蜘蛛俠TG@abin789】-5679
【蜘蛛俠TG@abin789】-5680
【蜘蛛俠TG@abin789】-5681
【蜘蛛俠TG@abin789】-5682
【蜘蛛俠TG@abin789】-5683
【蜘蛛俠TG@abin789】-5684
【蜘蛛俠TG@abin789】-5685
【蜘蛛俠TG@abin789】-5686
【蜘蛛俠TG@abin789】-5687
【蜘蛛俠TG@abin789】-5688
【蜘蛛俠TG@abin789】-5689
【蜘蛛俠TG@abin789】-5690
【蜘蛛俠TG@abin789】-5691
【蜘蛛俠TG@abin789】-5692
【蜘蛛俠TG@abin789】-5693
【蜘蛛俠TG@abin789】-5694
【蜘蛛俠TG@abin789】-5695
【蜘蛛俠TG@abin789】-5696
【蜘蛛俠TG@abin789】-5697
【蜘蛛俠TG@abin789】-5698
【蜘蛛俠TG@abin789】-5699
【蜘蛛俠TG@abin789】-5700
【蜘蛛俠TG@abin789】-5701
【蜘蛛俠TG@abin789】-5702
【蜘蛛俠TG@abin789】-5703
【蜘蛛俠TG@abin789】-5704
【蜘蛛俠TG@abin789】-5705
【蜘蛛俠TG@abin789】-5706
【蜘蛛俠TG@abin789】-5707
【蜘蛛俠TG@abin789】-5708
【蜘蛛俠TG@abin789】-5709
【蜘蛛俠TG@abin789】-5710
【蜘蛛俠TG@abin789】-5711
【蜘蛛俠TG@abin789】-5712
【蜘蛛俠TG@abin789】-5713
【蜘蛛俠TG@abin789】-5714
【蜘蛛俠TG@abin789】-5715
【蜘蛛俠TG@abin789】-5716
【蜘蛛俠TG@abin789】-5717
【蜘蛛俠TG@abin789】-5718
【蜘蛛俠TG@abin789】-5719
【蜘蛛俠TG@abin789】-5720
【蜘蛛俠TG@abin789】-5721
【蜘蛛俠TG@abin789】-5722
【蜘蛛俠TG@abin789】-5723
【蜘蛛俠TG@abin789】-5724
【蜘蛛俠TG@abin789】-5725
【蜘蛛俠TG@abin789】-5726
【蜘蛛俠TG@abin789】-5727
【蜘蛛俠TG@abin789】-5728
【蜘蛛俠TG@abin789】-5729
【蜘蛛俠TG@abin789】-5730
【蜘蛛俠TG@abin789】-5731
【蜘蛛俠TG@abin789】-5732
【蜘蛛俠TG@abin789】-5733
【蜘蛛俠TG@abin789】-5734
【蜘蛛俠TG@abin789】-5735
【蜘蛛俠TG@abin789】-5736
【蜘蛛俠TG@abin789】-5737
【蜘蛛俠TG@abin789】-5738
【蜘蛛俠TG@abin789】-5739
【蜘蛛俠TG@abin789】-5740
【蜘蛛俠TG@abin789】-5741
【蜘蛛俠TG@abin789】-5742
【蜘蛛俠TG@abin789】-5743
【蜘蛛俠TG@abin789】-5744
【蜘蛛俠TG@abin789】-5745
【蜘蛛俠TG@abin789】-5746
【蜘蛛俠TG@abin789】-5747
【蜘蛛俠TG@abin789】-5748
【蜘蛛俠TG@abin789】-5749
【蜘蛛俠TG@abin789】-5750
【蜘蛛俠TG@abin789】-5751
【蜘蛛俠TG@abin789】-5752
【蜘蛛俠TG@abin789】-5753
【蜘蛛俠TG@abin789】-5754
【蜘蛛俠TG@abin789】-5755
【蜘蛛俠TG@abin789】-5756
【蜘蛛俠TG@abin789】-5757
【蜘蛛俠TG@abin789】-5758
【蜘蛛俠TG@abin789】-5759
【蜘蛛俠TG@abin789】-5760
【蜘蛛俠TG@abin789】-5761
【蜘蛛俠TG@abin789】-5762
【蜘蛛俠TG@abin789】-5763
【蜘蛛俠TG@abin789】-5764
【蜘蛛俠TG@abin789】-5765
【蜘蛛俠TG@abin789】-5766
【蜘蛛俠TG@abin789】-5767
【蜘蛛俠TG@abin789】-5768
【蜘蛛俠TG@abin789】-5769
【蜘蛛俠TG@abin789】-5770
【蜘蛛俠TG@abin789】-5771
【蜘蛛俠TG@abin789】-5772
【蜘蛛俠TG@abin789】-5773
【蜘蛛俠TG@abin789】-5774
【蜘蛛俠TG@abin789】-5775
【蜘蛛俠TG@abin789】-5776
【蜘蛛俠TG@abin789】-5777
【蜘蛛俠TG@abin789】-5778
【蜘蛛俠TG@abin789】-5779
【蜘蛛俠TG@abin789】-5780
【蜘蛛俠TG@abin789】-5781
【蜘蛛俠TG@abin789】-5782
【蜘蛛俠TG@abin789】-5783
【蜘蛛俠TG@abin789】-5784
【蜘蛛俠TG@abin789】-5785
【蜘蛛俠TG@abin789】-5786
【蜘蛛俠TG@abin789】-5787
【蜘蛛俠TG@abin789】-5788
【蜘蛛俠TG@abin789】-5789
【蜘蛛俠TG@abin789】-5790
【蜘蛛俠TG@abin789】-5791
【蜘蛛俠TG@abin789】-5792
【蜘蛛俠TG@abin789】-5793
【蜘蛛俠TG@abin789】-5794
【蜘蛛俠TG@abin789】-5795
【蜘蛛俠TG@abin789】-5796
【蜘蛛俠TG@abin789】-5797
【蜘蛛俠TG@abin789】-5798
【蜘蛛俠TG@abin789】-5799
【蜘蛛俠TG@abin789】-5800

0 回復 有任何疑惑可以回復我~

package com.user.Widget;


import android.content.Context;

import android.graphics.Canvas;

import android.graphics.Color;

import android.graphics.Paint;

import android.graphics.Rect;

import android.graphics.RectF;

import android.os.Handler;

import android.os.SystemClock;

import android.view.MotionEvent;

import android.widget.Adapter;

import android.widget.ListView;

import android.widget.SectionIndexer;


public class IndexScroller {


private Context mContext;

private ListView mListView = null;


private float mIndexbarWidth; // 索引條的寬度,

private float mIndexbarMargin; // 索引條離右側(cè)邊緣的距離

private float mPreviewPadding; // 點擊中間顯示的索引文本,距離四周的距離

private float mDensity; // 當前屏幕密度除以160

private float mScaledDensity; // 當前屏幕密度除以160(設置字體的尺寸)

private float mAlphaRate; // 索引條透明度(用來顯示和隱藏索引條)0-1

private int mState = STATE_HIDDEN; // 索引條當前狀態(tài)

private int mListViewWidth; // 屏幕的寬度

private int mListViewHeight; // 屏幕的高度

private int mCurrentSection = -1; // 當前所點擊的索引值

private boolean mIsIndexing = false;

private SectionIndexer mIndexer = null;

private String[] mSections;

private RectF mIdexbarRect; // 繪制索引條區(qū)域


public static final int STATE_HIDDEN = 0;

public static final int STATE_SHOWING = 1;

public static final int STATE_SHOW = 2;

public static final int STATE_HIDDENING = 3;


public IndexScroller(Context mContext, ListView mListView) {

this.mContext = mContext;

this.mListView = mListView;

// 獲取當前屏幕的密度比值

mDensity = mContext.getResources().getDisplayMetrics().density;

// 獲取字體密度比值

mScaledDensity = mContext.getResources().getDisplayMetrics().scaledDensity;

setAdapter(mListView.getAdapter());

// 根據(jù)屏幕的 密度比值來調(diào)整索引條的寬度(單位:像素)

mIndexbarWidth = 20 * mDensity;

mIndexbarMargin = 10 * mDensity;

mPreviewPadding = 5 * mDensity;


}


public void setAdapter(Adapter adapter) {

if (adapter instanceof SectionIndexer) {

mIndexer = (SectionIndexer) adapter;

mSections = (String[]) mIndexer.getSections();

}

}


/**

* 繪制索引條和預覽文本

*?

* @param mPaint

*/

public void draw(Canvas mCanvas) {

// 1、繪制索引條和背景

// 2、繪制預覽文本和背景

if (mState == STATE_HIDDEN) {

return;

}

/**

* 繪制索引條的區(qū)域

*/

Paint mPaint = new Paint();

mPaint.setColor(Color.BLACK);

mPaint.setAlpha((int) (64 * mAlphaRate)); // 設置透明度,逐漸顯示


// 繪制索引條(四個角都是圓角區(qū)域)

mCanvas.drawRoundRect(mIdexbarRect, 5 * mDensity, 5 * mDensity, mPaint);


/**

* 繪制預覽文本背景和文字

*/

if (mSections != null && mSections.length > 0) {

// 繪制預覽文本背景和文字 , 大于0則點擊

if (mCurrentSection > 0) {

Paint previewPaint = new Paint(); // 繪制文本畫筆

previewPaint.setColor(Color.BLACK);

previewPaint.setAlpha(96);


Paint previewTextPaint = new Paint(); // 繪制文字畫筆

previewTextPaint.setColor(Color.WHITE);

previewTextPaint.setTextSize(50 * mScaledDensity);


// 獲取文本字體的寬度

float previewTextWidth = previewTextPaint

.measureText(mSections[mCurrentSection]);

// 獲得顯示文本的區(qū)域?qū)捀叨?= 上下間距padding + 字母往下超過基準線的高度(正值) +

// 字母在基準線的上面的高度(負值,負負得正)

float previewSize = 2 * mPreviewPadding

+ previewTextPaint.descent()

- previewTextPaint.ascent();

// 預覽文本區(qū)域所在位置

// 左=(屏幕寬度-顯示文本區(qū)域?qū)挾龋? 2 上= (屏幕高度-顯示文本區(qū)域高度)/ 2

RectF previewRectF = new RectF(

(mListViewWidth - previewSize) / 2,

(mListViewHeight - previewSize) / 2,

(mListViewWidth - previewSize) / 2 + previewSize,

(mListViewHeight - previewSize) / 2 + previewSize);


// 繪制預覽文本背景

mCanvas.drawRoundRect(previewRectF, 5 * mDensity, 5 * mDensity,

previewPaint);

// 繪制預覽文本的字體

mCanvas.drawText(

mSections[mCurrentSection],

(previewRectF.left + (previewSize - previewTextWidth)

/ 2 + 1),

(previewRectF.top + mPreviewPadding

- previewTextPaint.ascent() + 1),

previewTextPaint);


}

}


/**

* 設置索引字母

*/

// 設置繪制索引字母的屬性

Paint indexPaint = new Paint();

indexPaint.setColor(Color.WHITE);

indexPaint.setAlpha((int) (255 * mAlphaRate));

indexPaint.setTextSize(12 * mScaledDensity);

// 取得索引中每個字母的區(qū)域高度 = (索引區(qū)域高度 - 上下margin值 )/索引的長度length

float sectionHeight = ((mIdexbarRect.height() - 2 * mIndexbarMargin) / mSections.length);

// 設置每個字母區(qū)域中的文字的padding值 = (每個字母區(qū)域 - 文字高度)/2

float sectionPaddingTop = ((sectionHeight - (indexPaint.descent() - indexPaint

.ascent())) / 2);


for (int i = 0; i < mSections.length; i++) {


// 取得繪制的文字的paddingLeft值

float sectionPaddingLeft = (mIndexbarWidth - indexPaint

.measureText(mSections[i])) / 2;


// 開始繪制

mCanvas.drawText(mSections[i],

(mIdexbarRect.left + sectionPaddingLeft), mIdexbarRect.top

+ mIndexbarMargin + sectionPaddingTop * i/* 索引字母區(qū)域 */

+ sectionPaddingTop - indexPaint.ascent(),

indexPaint);

}

}


/**

* 保持最新的高度與寬度 重新加載索引條的區(qū)域

*?

* @param w

* @param h

* @param oldw

* @param oldh

*/

public void onSizeChanged(int w, int h, int oldw, int oldh) {

mListViewWidth = w;

mListViewHeight = h;


mIdexbarRect = new RectF(w - mIndexbarMargin - mIndexbarWidth,

mIndexbarMargin, w - mIndexbarMargin, h - mIndexbarMargin);


}


private void fade(long delay) {

// 0立即執(zhí)行,不延遲

// 清除消息

mHandler.removeMessages(0);

mHandler.sendEmptyMessageAtTime(0, SystemClock.uptimeMillis() + delay);

}


/**

* 判定狀態(tài)來顯示,并移除消息message

*/

private Handler mHandler = new Handler() {

public void handleMessage(android.os.Message msg) {

super.handleMessage(msg);


switch (mState) {

case STATE_HIDDENING:

mAlphaRate -= mAlphaRate * 0.2;

if (mAlphaRate < 0.1) {

mAlphaRate = 0;

setState(STATE_HIDDEN);

}

mListView.invalidate();

fade(10);

break;

case STATE_HIDDEN:

setState(STATE_SHOWING);

break;

case STATE_SHOWING:

mAlphaRate += (1 - mAlphaRate) * 0.2;

if (mAlphaRate > 0.9) {

mAlphaRate = 1;

setState(STATE_SHOW);

}

mListView.invalidate(); // listview不斷刷新,知道m(xù)AlphaRate > 0.9

fade(10);

break;

case STATE_SHOW:

setState(STATE_HIDDENING);

break;

}


};

};


/**

* 改變狀態(tài)

*?

* @param state

*/

private void setState(int state) {

if (state < STATE_HIDDEN || state > STATE_HIDDENING) {

return;

}

mState = state;

switch (mState) {

case STATE_SHOWING:

mAlphaRate = 0;

fade(0);

break;

case STATE_SHOW:

mHandler.removeMessages(0);

break;

case STATE_HIDDENING:

mAlphaRate = 1;

fade(3000); // 顯示的時間

break;

case STATE_HIDDEN:

mHandler.removeMessages(0);

break;


}

}


/**

* 管理觸摸索引條

*?

* @param ev

* @return

*/

public boolean onTouchEvent(MotionEvent ev) {

switch (ev.getAction()) {

case MotionEvent.ACTION_DOWN:

if (mState != STATE_HIDDEN && cantains(ev.getX(), ev.getY())) {

setState(STATE_SHOW);

mIsIndexing = true;

mCurrentSection = getSectionByPoint(ev.getY());

mListView.setSelection(mIndexer

.getPositionForSection(mCurrentSection));

return true;

}

break;


case MotionEvent.ACTION_MOVE:

if (mIsIndexing) {

if (cantains(ev.getX(), ev.getY())) {

mCurrentSection = getSectionByPoint(ev.getY());

mListView.setSelection(mIndexer

.getPositionForSection(mCurrentSection));

return true;

}

}

break;


case MotionEvent.ACTION_UP:

if (mIsIndexing) {

mIsIndexing = false;

mCurrentSection = -1;

}

if (mState == STATE_SHOW) {

setState(STATE_HIDDENING);

break;

}

}

return false;

}


/**

*?

* @param x

* @param y

* @return

*/

private boolean cantains(float x, float y) {


return (x >= mIdexbarRect.left && y >= mIdexbarRect.top && y <= mIdexbarRect.top

+ mIdexbarRect.height());

}

/**

*?

* @param y

* @return

*/

private int getSectionByPoint(float y) {

if (mSections == null || mSections.length == 0)

return 0;

if (y < mIdexbarRect.top + mIndexbarMargin)

return 0;

if (y >= mIdexbarRect.top + mIdexbarRect.height() - mIndexbarMargin)

return mSections.length - 1;

return (int) ((y - mIdexbarRect.top - mIndexbarMargin) / ((mIdexbarRect

.height() - 2 * mIndexbarMargin) / mSections.length));

}

/**

* show()

*/

public void show() {

if (mState == STATE_HIDDEN)

setState(STATE_SHOWING);

else if (mState == STATE_HIDDENING)

setState(STATE_HIDDENING);

}

/**

* hide()

*/

public void hide() {

if (mState == STATE_SHOW)

setState(STATE_HIDDENING);

}


}


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android高級特效-索引
  • 參與學習       30703    人
  • 解答問題       20    個

APP中的熟面孔,索引列表的實現(xiàn),有效增加了查找的便捷度

進入課程

求源碼。。。

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號