我一直在試圖建立一個可擴展的TextView
與5個系開始了(如果最初文本有超過5行)。TextView.SetMaxLines填充文本n行
我到目前爲止的代碼如下:
TextView
textView;
Button
button;
textView.LayoutChange += delegate {
if(textView.LineCount > 5) {
button.Visibility = ViewStates.Visible;
textView.SetMaxLines(5);
button.Click += delegate {
button.Visibility = ViewStates.Gone;
textView.SetMaxLines(Int32.MaxValue);
};
}
};
textView.Text = "Text that may occupy more than 5 lines due to size.";
基本上,我有一個TextView
其中I添加delegate
到LayoutChange
事件。之後,我將初始文本設置爲textView
。到現在爲止還挺好。如果文本跨越行數限制,則在設置文本後調用delegate
,並將textView
的MaxLines
設置爲5
。
的問題是,當用戶點擊button
,所述textView
MaxLines
被(到目前爲止,那麼好)設定爲Int32.MaxValue
但文本是填充 5行從頂部,切割的文本。
我試圖將MaxLines
設置爲0和Int32.MaxValue
和/或將文本設置爲""
,然後再次設置爲所需文本,但沒有結果。
任何有關發生了什麼事情的想法,或者我在這裏做錯了什麼?
編輯添加圖片說明發生了什麼。文本似乎填充了文本最初佔用的空間的相同數量,並設置了MaxLines
。
左邊圖像是textView
MaxLines
與設置爲5
,右側一個是textView
MaxLines
與設置爲Int32.MaxValue
。