android - 为什么外部 CustomViews 有红色锁?

标签 android github gradle dependencies

我最近添加了 this我的 Android 项目中的 GitHub 存储库,所以我继续添加我的 gradle 依赖项,如下所示:

dependencies {

    testCompile 'junit:junit:4.12'



    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.github.rey5137:material:1.2.2'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

当我放一个自定义 View 时,如果我使用带有绿锁的自定义 View ,那没关系,但是当我放一个带有红锁的 View 时,会出现“渲染问题”错误。

Here is the image of How it looks when I select it from the Custom Views

¿ 我应该怎么做?

最佳答案

您无法使用该依赖项做任何事情。
我们可以举个例子:

InternalEditText in EditText

这意味着 InternalEditText 是 EditText 的内部类。红色的锁表示它是一个私有(private)类,所以 EditText 类的结构是:
public class EditText {
    private class InternalEditText {

    }
}

所以你不能直接访问那个类。

解决方案
  • 反射(reflection):如果可以解决问题,不推荐
  • 项目的分支:您可以在 GitHub 上创建项目的分支,并在公共(public)类
  • 中更改这些类

    顺便说一句,你为什么要使用那些内部私有(private)类?该项目对于在 Lollipop 前设备上使用 Material 小部件很有用,因此对于 EditText(例如),您可以使用 com.rey.material.widget.EditText

    关于android - 为什么外部 CustomViews 有红色锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35384506/

    相关文章:

    java - getResource() 在 Gradle 项目中返回 null

    android - 错误显示在gradle同步

    javascript - Phonegap/Cordova 检查带有特殊字符的文件

    android - 如何在 Android Native Code 中使用 Keystore?

    GitHub 操作将 repo 作为 git 子模块 checkout

    api - 在 github api 中获取空的版本

    GitHub 统计数据不起作用

    android - 如何为 @Nullable 注释启用 Android lint 检查?

    java - java中的百分比函数

    java - 如何Android手机同时发送和扫描信标