我正在使用第三方库进行初始屏幕显示。我从https://github.com/ViksaaSkool/AwesomeSplash获得。我遵循了整个教程,但是在设置字符串路径时遇到错误。它有一条线
“ configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO); //设置路径字符串”。 Android Studio无法解析DR​​OID_LOGO,并且出现错误。我用DATA替换了DROID_LOGO并收到此错误。
正如帖子中建议的那样,我已经编写了此代码。

public class splashex extends AwesomeSplash {

//DO NOT OVERRIDE onCreate()!
//if you need to start some services do it in initSplash()!


@Override
public void initSplash(ConfigSplash configSplash) {

        /* you don't have to override every property */

    //Customize Circular Reveal
    configSplash.setBackgroundColor(R.color.colorPrimary); //any color you want form colors.xml
    configSplash.setAnimCircularRevealDuration(2000); //int ms
    configSplash.setRevealFlagX(Flags.REVEAL_RIGHT);  //or Flags.REVEAL_LEFT
    configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP

    //Choose LOGO OR PATH; if you don't provide String value for path it's logo by default

    //Customize Logo
    configSplash.setLogoSplash(R.mipmap.ic_launcher); //or any other drawable
    configSplash.setAnimLogoSplashDuration(2000); //int ms
    configSplash.setAnimLogoSplashTechnique(Techniques.Bounce); //choose one form Techniques (ref: https://github.com/daimajia/AndroidViewAnimations)


    //Customize Path
    configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO); //set path String(**I am getting error here**)
    //     configSplash.setOriginalHeight(400); //in relation to your svg (path) resource
    configSplash.setOriginalWidth(400); //in relation to your svg (path) resource
    configSplash.setAnimPathStrokeDrawingDuration(3000);
    configSplash.setPathSplashStrokeSize(3); //I advise value be <5
    configSplash.setPathSplashStrokeColor(R.color.colorPrimaryDark); //any color you want form colors.xml
    configSplash.setAnimPathFillingDuration(3000);
    configSplash.setPathSplashFillColor(R.color.colorPrimaryDark); //path object filling color


    //Customize Title
    configSplash.setTitleSplash("My Awesome App");
    configSplash.setTitleTextColor(R.color.colorAccent);
    configSplash.setTitleTextSize(30f); //float value
    configSplash.setAnimTitleDuration(3000);
    configSplash.setAnimTitleTechnique(Techniques.FlipInX);
    configSplash.setTitleFont("fonts/myfont.ttf"); //provide string to your font located in assets/fonts/

}

@Override
public void animationsFinished() {

    //transit to another activity here
    //or do whatever you want
}


}

我得到的错误是

  java.lang.RuntimeException: Font asset not found fonts/myfont.ttf
  at android.graphics.Typeface.createFromAsset(Typeface.java:190)


我搜索了各种链接,所有都建议添加资产文件夹,但我不知道在哪里制作资产文件夹以及在其中存储什么。
请帮助我了解有关素材资源和字体的所有详细信息。

我仍然得到这个。

android - 我不知道如何设置字符串路径-LMLPHP

最佳答案

您必须根据以下路径创建名为fonts的文件夹:

your_android_project_folder>应用> src>主>资产>字体

现在在fonts文件夹中,您需要存储myfont.ttf文件。

android - 我不知道如何设置字符串路径-LMLPHP

07-24 09:46
查看更多