2013-04-23 40 views
-1

在我的Android(API 10)遊戲中,我用MVC patternSurfaceView用畫布和ListView作爲輸入的選擇。Android - 畫布上的DrawText或TextView.draw

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" > 

<com.gorgo.pirates.MainGamePanel 
    android:id="@+id/surface" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" > 
</com.gorgo.pirates.MainGamePanel> 

<ListView 
    android:id="@+id/mylist" 
    android:layout_width="match_parent" 
    android:layout_height="110dp" 
    android:layout_gravity="center_horizontal|bottom" 
    android:background="@android:color/transparent" 
    android:cacheColorHint="@android:color/transparent" 
    android:divider="#00000000" 
    android:drawSelectorOnTop="true" > 
</ListView> 

所以現在我需要在屏幕上顯示出了很多字符串(字符或解說員文本之間的演講):他們在屏幕上停留4秒鐘,然後他們後來隱藏自理,我改變文本和重用他們等等。

我已經寫了this Class是工作,但它初始化的新TextViewdraw()呼叫O_O

但我發現,我不能創建3個或4 TextViewsetText每當我想,因爲我的外螺紋不能修改View。我嘗試過一個沒有成功的處理程序。

所以我在考慮canvas.drawText()但我不知道這是否正確。 我還需要我的字符串自動適合我的widht(Pastebin的類這樣做)並使用自定義字體。

提示? ?:(

回答

1

提示肯定的是,你必須使用這一個:http://developer.android.com/reference/android/text/Layout.html

+0

所以你建議我用的TextView,右 – Davide 2013-04-23 09:14:40

+0

沒有,使用Layout.draw(帆布C) – pskink 2013-04-23 09:23:30

+0

好的,我想StaticLayout。它似乎工作,但尺寸仍然太小,我不知道如何指定ax,y座標。 [Here](https://www.dropbox.com/s/s6ti3zp7heb2jxu/2013-04- 23%2016.53.06.png)一個例子,但我想[THIS](https://www.dropbox.com/s/mnvf3a3gvqs9z2t/2013-04-06%2016.55.27.png)。 [HERE] (http://pastebin.com/3BNVMqcR)你可以找到類 是寬度,間距多少,間距添加好嗎?我找不到任何文件對他們的誘惑:( – Davide 2013-04-23 15:01:16