2016-09-23 24 views

答えて

3

ui::Scrollviewの代わりに、ui::ListViewを使用する代わりに、ui::Textという1つの項目しか使用しないでください。これにより、ui::Textのテキストコンテンツを変更するときに、スクロールしてコンテナのサイズを動的に変更できます。

キーは、親ui::ListViewと同じサイズと0までの高さにui::Textの幅を設定する)であり、b)、リストビューいつでも上のテキストコンテンツの変更をmy_listview->requestDoLayout()を呼び出すようにスクロール可能な領域はそれを反映しています。ここで

はあなたが小さいにスクロールテキストの大きな体を実装したい方法の例です ui::Panel

ui::ListView* listview = ListView::create(); 
my_scene->addChild(listview); 
listview->setContentSize({300, 500}); //give it whatever size 

ui::Text* text = ui::Text::create("[multiline content]", "fontName.ttf", 16); 
text->setTextAreaSize({300, 0}); //use that same size, but use 0 height. This auto sets overflow and wrap in the backend 
listview->addChild(text); 
listview->requestDoLayout(); //this triggers resizing the listview to accommodate the 
          //string content. Needs to happen each time you 
          //text->setString(new_content) too. 
関連する問題