首页 \ 问答 \ 使用openGL在android中绘制一个圆(drawing a circle in android with openGL)

使用openGL在android中绘制一个圆(drawing a circle in android with openGL)

我正在寻找一种方法来绘制一个基本上充当地平线的圆圈的轮廓。 我不想填满这个圆圈,但是只要有一条白线可以看到,即使当你从侧面看它时,它也能看到它。这是可能的吗? 有人可以给我看一个教程或告诉我如何?


Im looking for a way to draw the OUTLINE of a circle that will basically act as a horizon line. I don't want to fill the circle, but instead just have a white line that can be seen even when you are looking at it from the side as it lays flat.. is this possible? can someone show me a tutorial or tell me how?


原文:https://stackoverflow.com/questions/9355004
更新时间:2022-05-01 07:05

最满意答案

更新:这是固定在Mosby 3.0.1。


这只是Mosby的一个Android工具问题。 android布局编辑器实际上实例化了一个MvpConstraintLayout实例,以在Android Studio中预览它。 然而,Android Studio并不是通过将一个像MvpContraintLayout这样的View MvpContraintLayout到一个真实的Activity MvpContraintLayout实现的,而是在内部使用了一些MvpContraintLayout “上下文”的东西。 Mosby的PresenterManager内部试图为你的MvpConstraintLayout找到一个Activity,但在Android Studio中没有使用真正的Activity( MvpConstraintLayout ),因此UI编辑器会显示此错误消息,并且在手机上安装时它会正常工作(因为有真正使用的活动)。

要解决这个问题,您必须在调用委托之前使用view.isInEditMode()

public abstract class MvpConstraintLayout<V extends MvpView, P extends MvpPresenter<V>>
        extends ConstraintLayout implements MvpView, ViewGroupDelegateCallback<V, P> {
    ...

    @Override protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (!isInEditMode()) getMvpDelegate().onAttachedToWindow();
    }

    @Override protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (!isInEditMode()) getMvpDelegate().onDetachedFromWindow();
    }

    @SuppressLint("MissingSuperCall") @Override protected Parcelable onSaveInstanceState() {
       if (!isInEditMode()) return getMvpDelegate().onSaveInstanceState();
       return super.onSaveInstanceState();
    }

    @SuppressLint("MissingSuperCall") @Override
    protected void onRestoreInstanceState(Parcelable state) {
        if (!isInEditMode()) getMvpDelegate().onRestoreInstanceState(state);
    }

    /**
     * Instantiate a presenter instance
     *
     * @return The {@link MvpPresenter} for this view
     */
    public abstract P createPresenter();

    @Override public P getPresenter() {
        return presenter;
    }

    @Override public void setPresenter(P presenter) {
        this.presenter = presenter;
    }

    @Override public V getMvpView() {
        return (V) this;
    }

    @Override public final Parcelable superOnSaveInstanceState() {
        return super.onSaveInstanceState();
    }

    @Override public final void superOnRestoreInstanceState(Parcelable state) {
        super.onRestoreInstanceState(state);
    }
}

实际上, ViewGroupMvpDelegate应该在内部处理。 这应该与Mosby 3.0.1修复。

请参阅https://github.com/sockeqwe/mosby/issues/229


UPDATE: This is fixed in Mosby 3.0.1.


This is just a android tooling issue with Mosby. The android layout editor actually instantiates a Instance of MvpConstraintLayout to preview it in Android Studio. However, Android Studio doesn't do that by attaching a View like MvpContraintLayout to a real Activity, but internally uses some mocked "context" alike thing. Mosby's PresenterManager internally tries to find an Activity for your MvpConstraintLayout, but in Android Studio there is no real Activity used (as already explained) and therefore the UI editor displays this error message and when installed on the phone it works properly (because there is a real Activity used).

To fix that you have to use view.isInEditMode() before calling the delegate like this:

public abstract class MvpConstraintLayout<V extends MvpView, P extends MvpPresenter<V>>
        extends ConstraintLayout implements MvpView, ViewGroupDelegateCallback<V, P> {
    ...

    @Override protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (!isInEditMode()) getMvpDelegate().onAttachedToWindow();
    }

    @Override protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (!isInEditMode()) getMvpDelegate().onDetachedFromWindow();
    }

    @SuppressLint("MissingSuperCall") @Override protected Parcelable onSaveInstanceState() {
       if (!isInEditMode()) return getMvpDelegate().onSaveInstanceState();
       return super.onSaveInstanceState();
    }

    @SuppressLint("MissingSuperCall") @Override
    protected void onRestoreInstanceState(Parcelable state) {
        if (!isInEditMode()) getMvpDelegate().onRestoreInstanceState(state);
    }

    /**
     * Instantiate a presenter instance
     *
     * @return The {@link MvpPresenter} for this view
     */
    public abstract P createPresenter();

    @Override public P getPresenter() {
        return presenter;
    }

    @Override public void setPresenter(P presenter) {
        this.presenter = presenter;
    }

    @Override public V getMvpView() {
        return (V) this;
    }

    @Override public final Parcelable superOnSaveInstanceState() {
        return super.onSaveInstanceState();
    }

    @Override public final void superOnRestoreInstanceState(Parcelable state) {
        super.onRestoreInstanceState(state);
    }
}

This is actually something ViewGroupMvpDelegate should take care of internally. This should be fixed with Mosby 3.0.1.

See https://github.com/sockeqwe/mosby/issues/229

相关问答

更多
  • 由于该问题被标记为C#和.NET 3.5,我假设以下.NET特定应用。 本页有提示zh-Hans,zh-Hant和“old”zh-CHS,zh-CHT 在.Net 2.0 / 3.x中使用IETF标准“zh-Hans”和中文简体和繁体中文的“zh-Hant”名称...我们仍然认识到zh-CHS和zh-CHT的向后兼容性... LCID (0x0004或0x7C04) 并从W3 I18N FAQ “zh-Hant”和“zh-Hans”。 这些语言代码不代表特定的语言。 “zh-Hant”表示用繁体中文字体书写 ...
  • 好吧,如果你看看这个统计数据,它表明歌剧自2002年以来越来越知名和流行,maby不是那么快但它仍然在增长。 我是之前习惯使用opera的人之一,它有一些非常好的功能,但是因为它们变得越来越大,它没有以前那么快,但它支持对FF和IE进行maskerading。 我支持它,如果它不是一个大问题,AFAIK歌剧可以很好地解释有效的HTML吗? Well if you take a look at this statistic it shows that opera is getting more known a ...
  • 它支持NVIDIA硬件,支持计算能力2.0和CUDA 3.1: 添加到CUDA C / C ++的 新语言功能 包括 : 对功能指针和递归的支持使得将许多现有算法更容易地连接到费米GPU http://developer.nvidia.com/object/cuda_3_1_downloads.html 函数指针: http : //developer.download.nvidia.com/compute/cuda/sdk/website/CUDA_Advanced_Topics.html#Functio ...
  • 最完整的答案是: Android 2.x默认浏览器本身不支持SVG。 Android 3+默认浏览器支持SVG。 要将SVG支持添加到2.x版本的平台,您有两个基本选择: 安装更强大的浏览器(如Firefox或Opera Mobile - 都支持SVG) 使用可以解析SVG并将其渲染到HTML5画布的JavaScript polyfill 第一个选项是好的,如果你只是想使SVG为个人用途或有限(可控制)的用户使用。 如果您希望在定位大型不受控制的用户群时使用SVG,这不是一个很好的选择。 在后一种情况下,您 ...
  • 在当前版本中,我们没有包含我们的可观察模式代码(v.2.6)。 您将在即将发布的版本中看到这一点,我们期望v.3.0提供全面支持。 延迟的原因是兼容性。 例如,我们需要实现一些可以包装的东西,以便与SlickGrid的数据模型和Kendo相同。 也就是说,了解在大多数JavaScript组件中都会公开自己的数据绑定模型。 因此,如果您在一组组件(例如Kendo)中工作,则您已经可以使用它们的可观察对象和DataSource以及所有工作。 因此,技巧(以及randori的难点)不是创建实现。 它有一个可以从A ...
  • 我注意到他们在Silverlight下载页面上列出了Mac的Silverlight 5 beta开发人员运行时 ,所以我想说,是的,它仍然支持。 I noticed they have a Silverlight 5 beta developer runtime for Mac listed on the Silverlight download page, so I would say, yes its still supported.
  • 更新:这是固定在Mosby 3.0.1。 这只是Mosby的一个Android工具问题。 android布局编辑器实际上实例化了一个MvpConstraintLayout实例,以在Android Studio中预览它。 然而,Android Studio并不是通过将一个像MvpContraintLayout这样的View MvpContraintLayout到一个真实的Activity MvpContraintLayout实现的,而是在内部使用了一些MvpContraintLayout “上下文”的东西。 ...
  • RequireJS和HTTP / 2之间没有直接关系。 这意味着HTTP / 2需要由浏览器实现,而不是库或JavaScript引擎。 更实际的一点是,可以使用RequireJS和HTTP / 2网站,前提是你有理由使用RequireJS。 这里是一个教程: https://www.shimmercat.com/en/blog/articles/angular-push/ There is no direct relationship between RequireJS and HTTP/2. Which ...
  • 根据我的个人经验,我发现大多数家庭用户使用现代浏览器(IE 9,Firefox,Chrome,Safari)。 合作用户是一个非常不同的故事。 他们通常使用自定义的遗留软件来阻止他们使用较新的浏览器。 Windows XP上还有不少人 (约占40%)。 这些通常是较旧的用户或懒惰的超级用户。 话虽如此,您的代码定位是哪些受众? 我知道开发人员会使用它,但这是针对企业还是更多基于消费者的网站? 考虑到所有事情,如果你的目标是公司,我会考虑IE 6+。 看到这是jQuery正式支持的 ,这是最佳解决方案。 但是 ...
  • 您需要创建一个新的Twig标记。 更多文档: https : //github.com/twigphp/Twig/blob/master/doc/advanced.rst#tags 此外, Twig_Node_Block将很好地了解您需要构建的内容: https : //github.com/twigphp/Twig/blob/1.x/lib/Twig/Node/Block.php You need to create a new Twig tag. More documentation here: htt ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)