我添加了一个新的字体cgib.ttf,我去了MainActivity.java添加了2个titleTexts这是activity_main.xml

    <RelativeLayout 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:background="#1d72c3"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="@string/titleText"
            android:textColor="#ffffff"
            android:textSize="55sp" />
        <TextView
            android:id="@+id/kark"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="@string/titleText2"
            android:textColor="#ffffff"
            android:textSize="30sp" />
    </LinearLayout>

这是MainActivity.java

package com.sa.damas;
import android.R;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initTypeFace();
        }
    private void initTypeFace() {
        Typeface cgib = Typeface.createFromAsset(getAssets(), "fonts/cgib.ttf");


        TextView titleText=(TextView) findViewById(R.id.title);
        titleText.setTypeface(cgib);


        TextView titleText2=(TextView) findViewById(R.id.kark);
        titleText2.setTypeface(cgib);
    }
}

标题是固定的,列表中找不到第二个(树皮)

===============>>#1 票数:0 已采纳

替换import android.R; import R;

android.R包含系统资源,而不是您项目的资源

  ask by Sa77a translate from so

未解决问题?本站智能推荐: