2016-11-04 19 views
0

基於文本的圖標,我工作的一個項目,其是由另一developer.To開發設置圖標,他用圖標代碼這樣
的Android:Android中

<string name="icAddress">\ue902</string> 
<string name="icAgeGroup">\ue903</string> 

我一般都用圖標作爲爲ImageView的,但他已經用它作爲customtextview這樣

<com.util.CustomTextView 
    android:id="@+id/tvIcAddress" 
    style="@style/menuIcon" 
    android:text="@string/icAddress" /> 

style.xml

<style name="menuIcon"> 
    <item name="android:layout_width">@dimen/dpSize50</item> 
    <item name="android:gravity">center</item> 
    <item name="android:textColor">@color/appColor</item> 
    <item name="android:layout_height">match_parent</item> 
    <item name="android:textSize">@dimen/bigTextSize</item> 
</style> 

該項目有一個字體文件在資產文件夾和CustomTextView他已經應用該字體使用setTypeface.I沒有得到這裏發生了什麼。現在我想在一些佈局中使用Skype圖標。我將如何以相同的方式使用它。我怎樣才能得到它的圖標代碼。

這裏是CustomTextViewFile

public class CustomTextView extends TextView { 

public CustomTextView(Context context) { 
    super(context); 
    applyCustomFont(context); 
} 

public CustomTextView(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    applyCustomFont(context); 
} 

public CustomTextView(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
    applyCustomFont(context); 
} 

private void applyCustomFont(Context context) { 
    setTypeface(Util.getIns().getCustomFont(context)); 
} 
} 

getCustomFont方法:佈局的

public Typeface getCustomFont(Context context) { 
    if (customTypeFace == null) { 
     customTypeFace = Typeface.createFromAsset(context.getAssets(), "hell.ttf"); 
     return customTypeFace; 
    } 
    return customTypeFace; 
} 

XML代碼:

<LinearLayout 
      android:id="@+id/linearMenu" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:id="@+id/linearHistory" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/dpSize45" 
       android:orientation="horizontal"> 

       <com.util.CustomTextView 
        android:id="@+id/tvIcCaseHistory" 
        style="@style/menuIcon" 
        android:text="@string/icCaseHistory" /> 

       <com.util.CustomTextView 
        android:id="@+id/tvCaseHistory" 
        style="@style/menuText" 
        android:text="Case History" /> 
      </LinearLayout> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="0.25dp" 
       android:layout_marginLeft="@dimen/dpSize50" 
       android:layout_marginRight="@dimen/dpSize15" 

       android:background="@color/appColor" /> 

      <LinearLayout 
       android:id="@+id/linearPrescription" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/dpSize45" 
       android:orientation="horizontal"> 

       <com.util.CustomTextView 
        android:id="@+id/tvIcPrescription" 
        style="@style/menuIcon" 
        android:text="@string/icPrescription" /> 

       <com.util.CustomTextView 
        android:id="@+id/tvPrescription" 
        style="@style/menuText" 
        android:text="Prescription" /> 

      </LinearLayout> 
</LinearLayout> 

截圖示出圖標:
link

+0

\ u902和\ u902是UTF字符不是圖像。你能分享屏幕截圖嗎? – USKMobility

+0

我已添加截圖請看看。 –

+0

您使用了哪種自定義字體?你可以分享佈局文件代碼嗎? – USKMobility

回答

0

的值,

<string name="icAddress">\ue902</string> 
    <string name="icAgeGroup">\ue903</string> 

是UTF編碼的字符,並表明字符他所使用的字體的資產文件夾, 任何UTF的相應字符可以找到; Here

在你的情況下,customtextview顯示指定的字符,你的應用程序中應該有一個圖像顯示在佈局中。

+0

我搜索了整個項目的圖像文件,但沒有找到一個。 –

相關問題