2017-04-14 115 views
0

歡迎 我有一個listview,其任務是顯示字符串文件「內部」數組中的文本,並通過單獨的行文件格式化文本我已經能夠從該行的文件,但我想設置的文本行我已經搜查了很多,並沒有解決問題的題中更改文本顏色...如何在列表視圖中設置自定義字體

排文件的XML:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

<TextView 
    android:id="@+id/row_text" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" 
    android:text="text" 
    android:textColor="@color/colorPrimaryDark" 
    android:textSize="30sp" 
    /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:srcCompat="@drawable/line"/> 
</LinearLayout> 
+0

你似乎缺少了你的問題的一些代碼 –

+0

也許這些帖子可以幫助您: http://stackoverflow.com/questions/7361135/how-to-change-color-and-font-on -listview http://stackoverflow.com/questions/18896887/android-change-listview-font-and-color – SergeS

回答

0

1 - 將您最喜歡的字體添加到資產文件夾(Roboto.ttf)中。例如,

2 - 將其添加到您的代碼中。

Typeface tf= Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf"); 
    Textview.setTypeface(tf); 
+0

我試過但這不起作用 –