gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 00:58:15 24 4
gpt4 key购买 nike

我正在为启动画面使用第三方库。我从https://github.com/ViksaaSkool/AwesomeSplash得到的.我已经按照整个教程进行操作,但是在设置字符串路径时出现错误。它有一条线“configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO);//设置路径字符串”。 Android Studio 无法解析 DROID_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)

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

我还是明白了。

added the font folder still i am getting the same error.

最佳答案

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

your_android_project_folder > app > src > main > assets > fonts

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

enter image description here

关于android - 我不知道如何设置字符串路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39826619/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com