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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

官方FlowLayout的使用,以及使用TagFlowLayout的一個(gè)問(wèn)題

標(biāo)簽:
Android

问题

一直使用的是鸿洋的TagFlowLayout,用于显示标签的自动换行问题。
但最近遇到一个问题:
如果内容过长则右边的内容会缺一块,如果是一个圆角背景则会被切掉一点。为此我花费了大量时间,用官方的FlowLayout替代解决这个问题。

需要注意的是,官方的也不能在添加的view上加左右的margin,否则也会出现上述问题,而TagFlowLayout也是代码里添加了增加margin造成的。

FlowLayout的使用

        <android.support.design.internal.FlowLayout
            android:id="@+id/tfl_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="17dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            app:itemSpacing="8dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_title"
            app:lineSpacing="8dp" />

不能在添加的view上加左右的margin,我们可以使用属性:

  • app:itemSpacing 每个tag之间的间隔
  • app:lineSpacing 行距

代码添加view:

    private void showTagView(android.support.design.internal.FlowLayout flowLayout, final List<ArticlesBean> beanList) {
        flowLayout.removeAllViews();
        for (int i = 0; i < beanList.size(); i++) {
            TextView textView = (TextView) View.inflate(flowLayout.getContext(), R.layout.layout_navi_tag, null);
            textView.setText(Html.fromHtml(beanList.get(i).getTitle()));
            flowLayout.addView(textView);
        }
    }

注意:

  • 完整路径名:android.support.design.internal.FlowLayout
  • app:itemSpacing 未知原因不能直接关联属性
  • 不能在view里直接设置 margin ,会出现圆角背景会被切掉的问题。
  • 如果使用 ConstraintLayout,则FlowLayout使用:layout_width="match_parent"
點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
移動(dòng)開(kāi)發(fā)工程師
手記
粉絲
8
獲贊與收藏
25

關(guān)注作者,訂閱最新文章

閱讀免費(fèi)教程

  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶(hù)
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專(zhuān)欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消