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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

根據(jù)文本量更改文本編輯的高度

根據(jù)文本量更改文本編輯的高度

瀟瀟雨雨 2022-09-01 19:50:15
因此,我試圖建立聊天和文本編輯你寫(xiě)消息的地方。我想根據(jù)文本量更改高度。要知道的一件好事也是,這是在一個(gè)片段中。就像在信使或普通的消息傳遞應(yīng)用程序中一樣。Kotlin:fun initTextWatcher(){        var tw: TextWatcher = object : TextWatcher {            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {                val textview = viewOfLayout.chat_input_text                if (activity != null) {                    activity?.runOnUiThread {                        textview.height = 100                    }                }            }            override fun afterTextChanged(s: Editable) {}            override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}        }        viewOfLayout.chat_input_text.addTextChangedListener(tw)    }XML: <android.support.constraint.ConstraintLayout            android:layout_width="0dp" android:layout_height="wrap_content"            android:background="@color/White"            app:layout_constraintEnd_toEndOf="parent"            app:layout_constraintStart_toStartOf="parent"            app:layout_constraintBottom_toBottomOf="parent"            android:id="@+id/chat_input_text_Send_container">        <Button                android:text="@string/Send"                android:layout_width="wrap_content"                android:layout_height="35dp"                android:id="@+id/chat_send_button" app:layout_constraintEnd_toEndOf="parent"                android:layout_marginEnd="10dp"                android:layout_marginBottom="10dp" app:layout_constraintBottom_toBottomOf="parent"                android:background="@drawable/chat_round_corners" android:textColor="@color/White"                android:textSize="15sp"/>
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

我通過(guò)在每次文本更改為的參數(shù)時(shí)設(shè)置布局參數(shù)來(lái)修復(fù)它。editText


fun initTextWatcher(){

        var tw: TextWatcher = object : TextWatcher {

            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {

                val chat_textedit = viewOfLayout.chat_input_text

                if (activity != null) {

                    activity?.runOnUiThread {

                        val lparams = chat_textedit.layoutParams as ConstraintLayout.LayoutParams

                        chat_textedit.layoutParams = lparams

                    }

            }

        }

        override fun afterTextChanged(s: Editable) {}

        override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}

    }

    viewOfLayout.chat_input_text.addTextChangedListener(tw)

}


查看完整回答
反對(duì) 回復(fù) 2022-09-01
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(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)