内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

php直播源碼如何實(shí)現(xiàn)TextView豎直滾動(dòng)

php直播源碼如何實(shí)現(xiàn)TextView豎直滾動(dòng),針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

公司主營(yíng)業(yè)務(wù):網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶(hù)真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶(hù)帶來(lái)驚喜。成都創(chuàng)新互聯(lián)推出郊區(qū)免費(fèi)做網(wǎng)站回饋大家。

public class AutoScrollTextView extends TextSwitcher implements
        ViewSwitcher.ViewFactory {
    private static final int FLAG_START_AUTO_SCROLL = 1001;
    private static final int FLAG_STOP_AUTO_SCROLL = 1002;
    /**
     * 輪播時(shí)間間隔
     */
    private int scrollDuration = 2000;
    /**
     * 動(dòng)畫(huà)時(shí)間
     */
    private int animDuration = 1000;
    /**
     * 文字大小
     */
    private float mTextSize = 14;
    /**
     * 文字Padding
     */
    private int mPadding = 20;
    /**
     * 文字顏色
     */
    private int textColor = Color.BLACK;
    private OnItemClickListener itemClickListener;
    private Context mContext;
    /**
     * 當(dāng)前顯示Item的ID
     */
    private volatile int currentId = -1;
    private CopyOnWriteArrayList<String> textList;
    private Handler handler;
    public AutoScrollTextView(Context context) {
        this(context, null);
        mContext = context;
    }
    public AutoScrollTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        init();
    }
    @SuppressLint("HandlerLeak")
    private void init() {
        textList = new CopyOnWriteArrayList<>();
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case FLAG_START_AUTO_SCROLL:
                        if (textList.size() > 0) {
                            currentId++;
                            setText(textList.get(currentId % textList.size()));
                        }
                        handler.sendEmptyMessageDelayed(FLAG_START_AUTO_SCROLL, scrollDuration);
                        break;
                    case FLAG_STOP_AUTO_SCROLL:
                        handler.removeMessages(FLAG_START_AUTO_SCROLL);
                        break;
                }
            }
        };
        setFactory(this);
        Animation in = new TranslateAnimation(0, 0, 300, 0);
        in.setDuration(animDuration);
        in.setInterpolator(new AccelerateInterpolator());
        Animation out = new TranslateAnimation(0, 0, 0, -300);
        out.setDuration(animDuration);
        out.setInterpolator(new AccelerateInterpolator());
        setInAnimation(in);
        setOutAnimation(out);
    }
    /**
     * 設(shè)置數(shù)據(jù)源
     *
     * @param titles
     */
    public void setTextList(ArrayList<String> titles) {
        textList.clear();
        textList.addAll(titles);
        currentId = -1;
    }
    public void setText1(String text) {
        if (TextUtils.isEmpty(text)) {
            return;
        }
        stopAutoScroll();
        int width = getWidth() - mPadding * 2;
        TextPaint paint = new TextPaint();
        paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTextSize, mContext.getResources().getDisplayMetrics()));
        if (width < paint.measureText(" ")) {
            return;
        }
        List<String> lineList = new ArrayList<>();
        StringBuilder newLine = new StringBuilder();
        for (int i = 0; i < text.length(); i++) {
            if ('\n' == text.charAt(i)) {
                lineList.add(newLine.toString());
                newLine.setLength(0);
            } else {
                newLine.append(text.charAt(i));
                if (paint.measureText(newLine.toString()) > width) {
                    lineList.add(newLine.toString().substring(0, newLine.toString().length() - 1));
                    i--;
                    newLine.setLength(0);
                } else {
                    if (i == text.length() - 1) {
                        lineList.add(newLine.toString());
                        newLine.setLength(0);
                        break;
                    }
                }
            }
        }
        textList.clear();
        textList.addAll(lineList);
        currentId = -1;
    }
    /**
     * 開(kāi)始輪播
     */
    public void startAutoScroll() {
        if (textList.isEmpty()) {
            return;
        }
        if (textList.size() == 1) {
            setText(textList.get(0));
            return;
        }
        handler.removeCallbacksAndMessages(null);
        handler.sendEmptyMessage(FLAG_START_AUTO_SCROLL);
    }
    /**
     * 停止輪播
     */
    public void stopAutoScroll() {
        handler.sendEmptyMessage(FLAG_STOP_AUTO_SCROLL);
    }
    @Override
    public View makeView() {
        TextView t = new TextView(mContext);
        t.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        t.setMaxLines(1);
        t.setPadding(mPadding, mPadding, mPadding, mPadding);
        t.setTextColor(textColor);
        t.setTextSize(mTextSize);
        t.setClickable(true);
        t.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemClickListener != null && textList.size() > 0 && currentId != -1) {
                    itemClickListener.onItemClick(currentId % textList.size());
                }
            }
        });
        return t;
    }
    /**
     * 設(shè)置點(diǎn)擊事件監(jiān)聽(tīng)
     */
    public void setOnItemClickListener(OnItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }
    /**
     * 輪播文本點(diǎn)擊監(jiān)聽(tīng)器
     */
    public interface OnItemClickListener {
        /**
         * 點(diǎn)擊回調(diào)
         *
         * @param position 當(dāng)前點(diǎn)擊ID
         */
        public void onItemClick(int position);
    }
}

關(guān)于php直播源碼如何實(shí)現(xiàn)TextView豎直滾動(dòng)問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

當(dāng)前題目:php直播源碼如何實(shí)現(xiàn)TextView豎直滾動(dòng)
標(biāo)題鏈接:http://www.rwnh.cn/article28/gddocp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站建設(shè)、企業(yè)網(wǎng)站制作、網(wǎng)站內(nèi)鏈、標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(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)

手機(jī)網(wǎng)站建設(shè)
津南区| 从江县| 姜堰市| 民权县| 山东省| 轮台县| 辰溪县| 兴化市| 罗源县| 六安市| 铁力市| 衡阳县| 凤阳县| 扬中市| 横山县| 吉首市| 察雅县| 孙吴县| 阿勒泰市| 松江区| 浮山县| 中牟县| 湖州市| 垦利县| 大理市| 云安县| 宜州市| 若羌县| 麦盖提县| 正定县| 鄂伦春自治旗| 盐池县| 长顺县| 泽普县| 仪陇县| 通化市| 钟祥市| 南澳县| 瑞金市| 乌兰县| 美姑县|