使MagicTextView成为导致R的库无法解析为变量

时间:2013-12-09 10:06:20

标签: android textview rjava

我试图将MagicTextView导入到我的项目中,以便我可以使TextView的内部流可见。我使用File-> import->现有项目将其导入工作区,并通过单击项目属性的“Android”选项卡的“Is Library”将其设为库。

然后我打开我的项目转到属性的Android属性并单击添加并添加MagicTextView作为库然后我收到R无法解析为我的项目中的变量导致下面的MagicTextView中的xml错误。

 error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout /main.xml:10: error: No resource identifier found for attribute 'foreground' in package   'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeJoinStyle' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:30 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'foreground' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'innerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowDy' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'outerShadowRadius' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeColor' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeJoinStyle' in package 'com.qwerjk.better_text'
[2013-12-09 14:49:31 - CCC] /home/asutosh/workspace/MagicTextView/res/layout/main.xml:10: error: No resource identifier found for attribute 'strokeWidth' in package 'com.qwerjk.better_text'

但是,所有这些属性都在res中的值的attr中定义。

2 个答案:

答案 0 :(得分:0)

我也面临同样的问题.. 不要将它用作库。复制MagicTextView.java文件和您项目中的所有相关资源,然后使用它。它会起作用。

答案 1 :(得分:0)

像这样:

popUpScoreTextView = new MagicTextView(myContext);
    // popUpScoreTextView.addInnerShadow(0, -1, 0, 0xFFffffff);
    popUpScoreTextView.addOuterShadow(9, 0, 2, Color.BLACK);
    popUpScoreTextView.setStroke(2, Color.parseColor("#612d00"));
    popUpScoreTextView.setTypeface(MyTypfaces.get(myContext, "GROBOLD"));
    popUpScoreTextView.setTextSize(40);
    popUpScoreTextView.setTextColor(Color.parseColor("#ffb400"));
    RelativeLayout.LayoutParams popupScoreTextViewParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    popupScoreTextViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    popUpScoreTextView.setLayoutParams(popupScoreTextViewParams);
    // ((GamePlayActivity)myContext).addContentView(popUpScoreTextView,
    // popupScoreTextViewParams);
    popUpScoreTextView.setVisibility(TextView.INVISIBLE);

    if (popUpScoreTextView.getParent() != null)
        ((ViewGroup) popUpScoreTextView.getParent())
                .removeView(popUpScoreTextView);

    // popUpScoreTextView.setTypeface(Typeface.SANS_SERIF,
    // Typeface.BOLD_ITALIC);
    ((RelativeLayout) this.getParent()).addView(popUpScoreTextView);