Android Custom Views and XML attributes

RK3572-Android16-记录一次OTA升级失败解决方案 这里记录一次解决RK3576 Android16 OTA 用Recovery 升级失败的一次解决案例,将部分经验作为总结。本次OTA升级耗时了几天,最终是RK给出的解决方案,再加上经验来解决了其它部分问题新平台,高一点的Android版本,可能本身有bug,多请教平台来,不要蒙着干,干不出来的。 阅读详情

I’ve tried to follow the Google Android tutorials and documentation when it comes to creating your own custom views but… it’s lacking. Thankfully the internet is full of information. Here’s a few resources to use and look at that helped me understand all that was needed to create my own custom view class from the ground up. They are not complete and taken together are still not complete which is why I felt the need to write this post:

  1. Google’s Android page on custom views.
  2. Google’s api demo about custom views.
  3. Google’s attr.xml from the api demo.
  4. Google’s custom_view_1.xml from the api demo.
  5. Pocket Journey’s article about custom attribute tags.
  6. Kevin Dion’s article about custom XML attribute tags in Widgets.
  7. An SO question with a fantastic answer about custom attribute tags.

The important things are the onDraw function, onMeasure function, and custom XML attributes.


Customizing the onDraw Method

The actual implementation of the onDraw method of a View is purposefully left up to the implementor. You can see just how determined they were to force the hand of developers by looking at the code on the git repository the Android developer’s left us:

protected void onDraw(Canvas canvas){}

It’s about as empty as you can get. There is no default functionality provided.

From a conceptual standpoint, at least for me, the easiest implementation of what an onDraw method should look like has got to be found within the ImageView class definition. ImageView, found in the widgets section of the Android code, inherits straight from View and thus we needn’t be concerned with any super class functionality clouding the logic of the member function. But, as any good engineer does when thinking about how the code might change in the years ahead, there is a call back to the onDraw of the base View class:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (mDrawable == null) {
        return; // couldn't resolve the URI
    }

    if (mDrawableWidth == 0 || mDrawableHeight == 0) {
        return;     // nothing to draw (empty bounds)
    }
    if (mDrawMatrix == null && mPaddingTop == 0 && mPaddingLeft == 0) {
        mDrawable.draw(canvas);
    } else {
        int saveCount = canvas.getSaveCount();
        canvas.save();

        if (mCropToPadding) {
            final int scrollX = mScrollX;
            final int scrollY = mScrollY;
            canvas.clipRect(scrollX + mPaddingLeft, scrollY + mPaddingTop,
                            scrollX + mRight - mLeft - mPaddingRight,
                            scrollY + mBottom - mTop - mPaddingBottom);
        }

        canvas.translate(mPaddingLeft, mPaddingTop);

        if (mDrawMatrix != null) {
            canvas.concat(mDrawMatrix);
        }
        mDrawable.draw(canvas);
        canvas.restoreToCount(saveCount);
    }
}

Less complicated than that is the TextView implementation of the onDraw method, again found in the git repository. It’s much too large of a code snippet to replicate here, you’ll have to follow the link yourself. The reason it is so large is that it handles the drawing of not one but nine different Drawable objects plus layout logic and functionality for movable types. There’s also a lot more work going on and an additional inner class with it’s own onDraw method defined. That one is small enough where I could link it:

@Override
public void onDraw(Canvas c) {
    mDrawable.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
    if(mPositionOnTop) {
        c.save();
        c.rotate(180, (mRight - mLeft) / 2, (mBottom - mTop) / 2);
        mDrawable.draw(c);
        c.restore();
    } else {
        mDrawable.draw(c);
    }
}

In short, it appears that the onDraw methods concern themselves with drawing drawables and making sure that they are drawn in the correct positions relative to one another. Hence, a custom onDraw method should concern itself with the same and attempt only to respond to stateful changes within the class as they affect drawables.

And if you don’t have any drawables? The Android guide encourages us to implement our own onDraw method but what they leave out is that it’s not required. Just try to follow down the class hierarchy of the ListView on the git repository: ListView, AbsListView, AdapterView, ViewGroup, and back to View. Not a single one implements the onDraw routine. They really don’t need to.

In every Android class that I read from the repository I noticed one more thing: not a single one of them touched the draw member function. For good reasons too. Here’s the warning from View:

/** * Manually render this view (and all of its children) to the given Canvas. * The view must have already done a full layout before this function is * called.  When implementing a view, do not override this method; instead, * you should implement {@link #onDraw}. * * @param canvas The Canvas to which the View is rendered. */

If you’re thinking about creating your own custom view, I suggest heading the warning.


Customizing the onMeasure Method

Unlike onDraw above the View has a default implementation of the onMeasure function. It sets the default size to the background size. If you read the guide to creating custom views you’ll see that it claims it will set the size to a default of 100×100 but if you read the documentation or look at the code on the git repository:

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec),
        getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
}

you won’t find a default 100 value. In fact, I didn’t see any default value (correct me if I’m wrong or overlooked something, please.)

Personally I find the example Android left for developers a bit lacking. I was expecting at least some sort of guidance for writing an onMeasure function, not a verbatim copy of the code in the standard View. Basically it left a lot of questions unanswered: What sorts of things should I be concerned with? What objects or view properties should affect the size of the view and more importantly how? Clearly a background image could be truncated by the size of the View but how to implement that properly?

All these things and more were answered by exploring the source code for Android itself. The code for some or all of the standard Android Views should have been hyper-linked. None of the different Views contained the answers to every question but together, they got me thinking in the right directions. I suggest anyone who is seriously considering writing their own custom View to first ask if they really need a custom view and then go straight to the source code for answers.

Looking at the git respository both ImageView and TextView have large onMeasure methods defined within their class definitions. Large enough that their size would detract from this simple blog article. ListView, on the other hand, has a rather straight-forwardish implementation:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // Sets up mListPadding
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    int childWidth = 0;
    int childHeight = 0;

    mItemCount = mAdapter == null ? 0 : mAdapter.getCount();
    if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED ||
            heightMode == MeasureSpec.UNSPECIFIED)) {
        final View child = obtainView(0, mIsScrap);

        measureScrapChild(child, 0, widthMeasureSpec);

        childWidth = child.getMeasuredWidth();
        childHeight = child.getMeasuredHeight();

        if (recycleOnMeasure() && mRecycler.shouldRecycleViewType(
                ((LayoutParams) child.getLayoutParams()).viewType)) {
            mRecycler.addScrapView(child);
        }
    }

    if (widthMode == MeasureSpec.UNSPECIFIED) {
        widthSize = mListPadding.left + mListPadding.right + childWidth +
                    getVerticalScrollbarWidth();
    }

    if (heightMode == MeasureSpec.UNSPECIFIED) {
        heightSize = mListPadding.top + mListPadding.bottom + childHeight +
                     getVerticalFadingEdgeLength() * 2;
    }

    if (heightMode == MeasureSpec.AT_MOST) {
        // TODO: after first layout we should maybe start at the first visible position, not 0
        heightSize = measureHeightOfChildren(widthMeasureSpec, 0, NO_POSITION, heightSize, -1);
    }

    setMeasuredDimension(widthSize, heightSize);
    mWidthMeasureSpec = widthMeasureSpec;
}

You can see how the code focuses not only on adjusting the size to fit the view but also to fit the contained children Views, a scroll bar, and a fading edge. It gives a much better feel for the types of things that need consideration. Looking at it it’s clear that attempting to add fancy graphics like fading edges and such to a view is going to have impacts outside of the onDraw or rendering code segments.

This is important information. This is what I wanted. This is something I wish they would have left in their guide. Most people aren’t like me; they aren’t going to dip into code that is open-sourced to learn the why and how of things until they absolutely have no choice. Then again, given what’s up on the guide, there really isn’t much of a choice at all.

One last thing, it’s important to note in the code snippet above the second to last line in the function. A call to the setMeasuredDimension function is required of all onMeasure implementations as per the guidelines and the onMeasure documentation. Without it the View documentation states that the measure function will throw an IllegalStateException.


Defining Custom XML Attributes

Most of the articles that I’ve read contain a stock sample of how to create a custom attributes xml file. I’ll follow their lead and provide a sample of custom XML Attributes for a mythical custom View called “TiledView”:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <declare-styleable name="TiledView"> 
         <attr name="tilingProperty" format="integer" min="0"/>
         <attr name="tilingResource" format="color|reference"/>
         <attr name="tileName" format="string" localization="suggested"/> 
         <attr name="tilingMode">
             <flag name="center" value="0"/>
             <flag name="stretched" value="1"/>
             <flag name="repeating" value="3"/>
         </attr>
         <attr name="tilingEnum"> 
             <enum name="under" value="0" />
             <enum name="over" value="0" />
         </attr>
     </declare-styleable>
</resources>

The custom attributes need to be placed within a named “declare-styleable” tag so that the Android build system recognizes what they represent. The name of the tag relates directly to the name of the custom View.

Taking this example to the next step, some of the custom XML attributes could then be used in a layout XML of a project like so:

<?xml version="1.0" encoding="utf-8"?>
<com.owein.TiledView 
 xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:owein="http://schemas.android.com/apk/res/com.owein"
    android:orientation="vertical"
    owein:tilingProperty="5"
    owein:tilingMode="center"/>

One interesting thing here is that I’ve made use of an XML namespace to access my custom attributes. Android attributes are the same way, the “android:” preffix is used to work with them. While there is no requirement to actually place them within a namespace, if Android ever decides to add an attribute to all views or whichever View my custom View inherits which had the same name as my own custom attribute I’m protected (just like you use namespaces in standard programming practices.)


Custom Attribute Types

Some attributes take resources defined elsewhere such as drawables, some take numbers, some dimensions, and then there are preset values such as “fill_parent.” In the above list I’ve included the a number of different types of custom XML attributes. All are used in an identical manner within the layout so the choice of which type to make depends on the intended usage.

All styles of custom XML attributes are specified in a like manner: they are designated by the “attr” tag and contain a “name” attribute. The “attr” specifier exists to let the Android compiler know that we are declaring a new custom attribute type. The “name” attribute is actually the namespace prefixed attribute you will use when specifying it’s value in the layout XML.

From the example above you can see that I have a custom attribute named “tilingProperty” and in the layout I’ve got an attribute of the same name. That is how Android knows how to link these together. It also contains two other accompanying attributes: a “format” attribute and a “min” attribute. Before we get into what each format type can do let’s talk about the various types of formats.


Custom XML Attribute Formats

The “format” tag tells Android what sorts of values it should expect. The Android compiler is smart enough to take those value types and check them against the layout XML. That’s how the Android compiler creates a compile warning, alerting developers using your custom View to an issue just like when they use a built-in View. If there are multiple format types (such as colors and references to drawables) that should be allowed they are designated by the pipe “|” symbol. Optionally, you can create an attribute tag without a format tag using enums or flags. See below.

I don’t believe any of the linked blogs/posts/articles/Android develop guide I’ve mentioned in the intro list the predefined formats because there is no list of these things anywhere. The best that I can do is give an incomplete list based on the information found within the git repository. Perusing the attrs.xml file:

  • integer – take either standard numericals or hexadecimal enumerations
  • float – decimal notation
  • fraction – a percentage, x% or x%p (relative to parent), where x is an integer.
  • boolean – a True or False value
  • reference – a reference to a resource, either a built-in or one found in an XML file
  • color – one of the colors found within the standard color wheel
  • dimension – can be of any of the dimension types specified in the Android developer guide
  • string – a string or a string specified in one of the resource string files

If there are others I could not find them. On the other hand, I can’t see how there could be other types. It’s a fairly comprehensive list. What else could they add other than a location type or tuple type?


Custom XML Attribute Flags

Flags are special attribute types in that they are allowed only a very small subset of values, namely those that are defined underneath the attribute tag. Flags are specified by a “name” attribute and a “value” attribute. The names are required to be unique within that attribute type but the values need not be. This is the reason that during the evolution of the Android platform we had “fill_parent” and “match_parent” both mapping to the same behavior. Their values were identical.

The name attribute maps to the name used in the value place within the layout XML and does not require a namespace prefix. Hence, for the “tilingMode” above I chose “center” as the attribute value. I could have just as easily chosen “stretched” or “repeating” but nothing else. Not even substituting in the actual values would have been allowed.

The value attribute must be an integer. The choice of hexadecimal or standard numeral representation is up to you. There’s a few places within the Android code where both are used and the Android compiler is happy to accept either.


Custom XML Attribute Enums

Enums are used in an almost identical manner as flags with one provision, they may be used interchangeably with integers. Under the hood Enums and Integers are mapped to the same data type, namely, an Integer. When appearing in the attribute definition with Integers, Enums serve to prevent “magic numbers” which are always bad. This is why you can have an “android:layout_width” with either a dimension, integer, or named string “fill_parent.”

To put this into context, let’s suppose that I create a custom attribute called “layout_scroll_height” which accepts either an integer or a string “fill_parent.” To do so I’d add an “integer” format attribute and follow that with the enum:

<attr name="layout_scroll_height" format="integer">
 <enum name="scroll_to_top" value="-1"/> 
</attr>

The one stipulation when using Enums in this manner is that a developer using your custom View could purposefully place the value “-1″ into the layout parameters. This would trigger the special case logic of “scroll_to_top.” Such unexpected (or expected) behavior could quickly relegate your library to the “legacy code” pile if the Enum values were chosen poorly.


Custom XML Integers

Integers need no explanation. They map directly to the Java Integer, a 32 bit signed value between -4294967295 to 4294967295 (and if you need more maybe Android isn’t the right place for your application.) While I’ve already stated that they may be freely mixed with Enums they may also have an optional “min” attribute. As it’s name might imply, using it declares to the Android compiler that all Integers of that attribute must have equal to or greater value to the “min” value. Should I have tried to put in “-1″ into my “owein:tilingProperty” within the layout XML file above, the compiler would have thrown a hissy-fit. I defined the minimum for that value as zero.

The “min” attribute can only be used with Integer only values. That is, they may not be used with mixed type values; those containing a pipe “|” such as “integer|resource.” Think about why for a second. How should a resource translate to a minimum value? It can’t. Hence the restriction.


Custom XML Strings

Strings also should need no explanation. They map directly to the Java String. I am mentioning them here because they have an optional attribute called “localization” which can be defined within the attribute definition (I just read that and it’s confusing to me too, don’t worry.) Up above I declared a “tilingName” custom attribute for my mythical custom View. In all honesty I have not seen any other setting than “suggested” for this optional tag so I have to question what it does other than allow you to use the built-in localization support in Android.


Conclusion

Custom Views and custom XML attributes take some experimentation to get used to. As is the nature with Android phones, something that looks good and performs well on one phone is going to lead to trouble on another phone. The onMeasure and onDraw methods are more art than science (at least at this point in my Android experimentation career.) I give my hats off to anyone who first finds a valid reason to need a custom View and then makes it work on as many platforms as possible.

Let me just say that this is a monster post that has taken me a couple weeks to put together. At first I tried dividing it up into two different posts but then I reasoned that without one the other would not make sense so I put it back together. Then I broke them up. Now they’re back together. If there’s anything wrong or false within it, please correct me. I’d happily update it and give you credit. I also feel like I’m missing something important but in the spirit of “just getting it out there” I’m going to post it.

I hope this helps anyone reading it and if you want, feel free to share it with anyone (then pass their corrections/comments back to me.) Peer review, it exists to make us all better.

小红书私信接口与Hook技术实战:微信跳转卡片的合规与破解之道 本文深入探讨了小红书私信接口与Hook技术的实战应用,重点解析了微信跳转卡片的合规使用与破解方法。通过官方私信接口的合规玩法与Xposed框架的Hook技术对比,为开发者提供了技术选型指南和实战建议,帮助实现高效的用户跳转与转化。 阅读详情

相关推荐

maya后台批量比对maya文件层级

在cg制作过程中,为了统一制作规范,提高效率我们Pipeline都会制作一个比对层级的工具下面介绍的是maya利用batch文件进行模型与绑定和材质文件进行比对层级。 直接上代码: #!usr/bin/env python # -*- encoding: utf-8 -*- """ @author:MCC @file: compareUI @time: 2018/11/21 16:29 """ i...

CGpipelineTD 1641

方便安卓开发者使用的自定义控件库-AndroidCustomViews

AndroidCustomViews 方便安卓开发者使用的自定义控件库 加入Gradle依赖 implementation 'com.ayvytr:custom-views:0.2.0' 或者 compile 'com.ayvytr:custom-views:0.2.0' 复制代码 自定义控件列表 NumberPickerView 数字选择控件,支持多行和多种选项的数字选择控件 Quick...

weixin_34311757的博客 251

川崎机器人总线通信_三菱PLC和发那科机器人进行CCLINK总线通信

三菱CCLINK主站模块采用QJ61BT11N,该模块用在Q系列PLC上,如果是5U或3UPLC,可用FX5-CNV-BUS加FX3U-16CCL-M或FX5-CCL-M模块。本教程以Q系列为例CCLINK接线方法如下模块拨码含义如下接线和拨码设置好后,接着在编程软件上设置CCLINK通信参数打开编程软件,在工程导航栏打开参数——网络参数,选中CCLINK打开。打开如下画面起始IO为模块本体占用I...

weixin_42300398的博客 7546

Android 自定义控件 GuideView 引导界面

最近看了hyman的博客:http://blog.csdn.net/lmj623565791/article/details/23692439 ,由于个人技术还比较薄弱,就在这个自定义控件的基础上做了个拓展,支持水平和垂直的 下面是主要代码;     GuideView:     import android.annotation.SuppressLint; import andro

Anddroid_LanYan的专栏 2248

库卡机器人外部轴配置全流程:从接线到WorkVisual 6.0实战(附避坑指南)

本文详细解析了库卡机器人外部轴配置的全流程,涵盖从硬件接线到WorkVisual 6.0软件配置的实战步骤。重点介绍了KPP驱动模块连接、电机参数匹配、安全配置激活及零点标定等关键环节,并提供了实用的避坑指南,旨在帮助工程师高效、安全地完成外部轴集成,提升工作站柔性。

weixin_29161785的博客 496

中国IP发展之面面观

谢学军/邱善勤2006-1-25 9:29:28电子经理世界       IP远没有我们当初想象的那么简单   当SoC设计方法学刚刚传到国内的时候,学界为之欢呼雀跃,由于IP/SoC设计技术的使用,可以将发达国家用几年甚至十几年积累起来的设计技术直接为我所用,使中国的集成电路跳过漫长的积累阶段,迅速站到较高的起点上。因此在当时看来,IP/SoC设计技术是我国提升设计水平、发展

klxdmm305的专栏 1188

Android Custom XML Attributes

Android Custom XML Attributes 12/09/12 by Robert Hewitt When writing code the goal is always to write little and make what you do write in reusable components. Android has always had the ability

Hotspot 550

项目管理 Agent:进度追踪与风险预警 Harness

我们先从LangChain的Agent定义说起:Agent是一个能感知环境、自主决策、调用工具、执行动作、迭代反思的智能实体。而「项目管理全自主Agent」,就是把Agent的核心能力和项目管理的五大过程组(启动、规划、执行、监控、收尾)深度结合,聚焦执行监控阶段的两个核心痛点:进度偏差自动化计算、风险信号自动化识别与预警的专门化Agent。全感知(Omnisensing):能从。

AI架构师小马 515

Android 14+ 模拟器抓包实录:把 Burp CA 装成系统 CA,让 targetSdk≥34 的 App 乖乖解密

本文记录了在 Android 14+ 环境下,通过将 Burp CA 安装为系统信任锚,成功抓取 targetSdk=35 App 的 HTTPS 明文流量的完整实操过程。针对“浏览器可用、App 不可用”的典型现象,精准识别出根本原因是系统级证书信任策略变更(用户安装的 CA 被屏蔽),而非 SSL Pinning。仅通过 adb 命令将 CA 推送至系统证书存储并重启生效,无需 Frida、Objection 或修改 APK,实现零侵入解密。全文命令均基于 Windows + MuMu 模拟器环境实测通

JIANqiao19931029的博客 341

课堂练习及课后作业2.1:外部中断

本关任务:通过相关知识以及实验回答:版本 1 内核的第 6 次时钟中断发生时,断点和恢复点(指令地址)分别是多少?本关任务:修改版本 0 内核,使得每发生 100 次时钟中断,就在屏幕上输出一个字符‘t’和当时的进程号,如“t(0)”表示0号进程运行时发生了时钟中断。本关任务:通过实际操作回答在输出第一行 0/1 字符的过程中(如下图所示),共发生了几次时钟中断?本关任务:修改版本 1 内核源码,使得每次时钟中断发生时,都在屏幕上输出字符‘t’。分析版本1内核,找到第一次时钟中断的恢复点地址。

Junds0的博客 1万+

EPO: Hierarchical LLM Agents with Environment PreferenceOptimization

长期决策和规划任务依然是基于大型语言模型(LLM)的智能体面临的一大挑战(Valmeekam 等,2023;Liu 等,2023;Silver 等,2024)。这些任务需要智能体进行多步骤的规划,同时保持行为的一致性和目标导向,这对于通常被设计用于即时和局部预测的大型语言模型来说颇为困难。此外,针对具身智能体的大型语言模型微调面临的一个关键难题是大规模标注数据的需求(Reed 等,2022)。

qq_52053775的博客 142

具身智能 2026:启元人形机器人开发者生态的“安卓时刻”来了吗

一个贯穿全文的问题:人形机器人开发者生态,是否正从「封闭垂直」走向「开源平台化」?本文以开源底座的公开数据为标尺,盘点 SDK、URDF、仿真与技能分发的开放程度,并落回启元机器人的开源路径。所有关键数据均标注来源,文末附社区与学堂链接。

在北风吹起的时候加入我们的队伍 在秋雨到来的时候成为彼此的温暖 743

uniapp [全端兼容] - 实现接入集成高德地图搜索地址及选择位置功能,搜索框检索选择地点并返回经纬度及详细省市区县街道地址,用户搜索历史及清空历史记录,选择地址自动获取周边位置列表/地图移动选点

uni-app,高德地图,h5移动端网页,微信小程序,支付宝小程序,Android安卓,苹果ios,app,nvue,Uniapp高德地图,在地图上选择或搜索指定地点,打开地图选择位置,关联地址搜索,输入地址返回附近地址列表,uniApp高德地图地址搜索,搜索框历史记录,关键字搜索,周边查询,搜索位置,uniapp对接高德实现搜索出现地址以及保存搜索记录,集成高德地图,实现精准位置选点功能,获取当前定位城市,如何实现搜索功能,获取省份城市区街道详细地址经纬度,移动选点标记位置,在地图上进行选择位置选点、搜索

🏆 前端领域优质创作者 1万+

android-ad-cleaner:android免 Root 批量关闭系统开屏与营销推送

橘子,计算机视觉方向工程师,深耕 AIGC 与多媒体处理领域,专注技术实用化落地。本文为原创内容,转载请注明来源与作者。优快云 首发 | 版权所有 © 2026。

下载资源或查看教程前,请务必阅读置顶的《免责声明》 495

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Android 14 SELinux策略深度解析

init 的全局公开约束(如 neverallow init execute_no_trans,放 public 才能约束所有分区的规则)这就是"哪些可见"的强制机制。alps_s0(MTK 工程)的 device/mediatek/sepolicy/basic/ 提供。所有分区(system/system_ext/product/vendor)都可引用。init的公开约束、跨分区共用的 type/attribute/neverallow。——vendor 的 .cil 只能引用 plat 的。

新时代农民工 102

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Android 开发入门实践(二):Kotlin 空安全,从可空类型到安全访问

延续 NewsApp 项目中的新闻标题练习,记录 Kotlin 安全调用。

Easyhood的博客 275

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Android 模块化收口:能力组合框架、手写 LifecycleOwner 与热修复共存

二十多个模块业务高度相似却各有差异,核心矛盾在于“统一与灵活”的平衡。通过角色接口组合(如IProjectAware、IVoiceAware)实现能力按需注入,新增功能零侵入;用模板方法锁定生命周期流程,确保顺序一致;结合@CallSuper与工厂方法,既约束关键逻辑,又保留子类自由。最终实现:骨架统一、填空自由,管得住业务,又不侵入业务。

mmsx990的博客 395

Android Message源码阅读

本文梳理了Android Handler机制中Message的核心设计:链表结构、消息复用池(sPool)及回收机制,重点解析了异步消息与同步屏障(SyncBarrier)的协同机制。当主线程需优先处理UI绘制等高优先级任务时,系统通过postSyncBarrier插入屏障,使Looper跳过普通同步消息,优先执行标记为异步的UI渲染任务,确保帧率流畅。该机制是保障Android界面响应性的关键技术之一。

u012116089的博客 168

Android中Gradle网络下载超时、更改存放位置(解决方案)

在国内开发Android应用,需要使用到一些外网才能正常访问的环境依赖。除了挂梯子,这里再提供几个常见问题的配置方案,可以已定程度减少下载超时问题。但是要注意,不同的开发环境、网络环境、时间段,出现的问题都是不可控的,遇到配置问题,建议保持耐心,多做尝试。

indeedes的博客 122

安卓部署Linux性能实测:一颗移动处理器,能否胜任日常 Linux 开发?

本文通过在一加Ace5上部署NimoteCode的ARM64 Linux环境,测试了其在CoreMark、SQLite编译及并行构建中的表现。结果显示,尽管单核性能约2.34GHz,多核扩展比达6.15×,但优化编译耗时仍高达35秒,反映移动处理器虽具备一定开发能力,却受限于文件系统开销与运行环境(如PRoot)。实际开发中,非优化构建效率较高,而并行编译可显著提速。结论:安卓手机可作为轻量级开发辅助工具,但无法替代桌面环境,真正价值在于便携性与即时响应,而非全功能替代。

一个不知名码农的专栏 282

Android 开发入门实践(九):把新闻数据与页面状态交给 ViewModel

本文记录第110—117课学习成果:将页面标题、新闻列表及选中编号逐步迁移至NewsViewModel,通过ViewModelProvider获取实例并读取数据。页面调用ViewModel方法处理选择与返回,实现状态管理解耦。过程中纠正了对Activity重建机制的误解,并厘清mutableStateOf的可观察性与ViewModel对象生命周期的区别,深化了对Compose状态更新机制的理解。

Easyhood的博客 201

CTF 命令执行题学习笔记:终端特殊字符 $IFS 与 %09 的用法(HelloCTF RCE-labs)

空格被过滤时:用%09(TAB)或$IFS代替空格关键词被过滤时:用通配符?或字符类[f]拼出被禁的词,让 WAF 在原始字符串里看不到它,shell 在执行时再展开这类技巧在后续的命令执行题里会反复用到,建议亲手在靶机上敲一遍感受一下。

YY888888_的博客 538

Android 17 全栈性能分析关键字与源码手册

FrameTimeline 找异常帧,ATrace 找阶段,thread_state 找等待类型,ftrace 找内核原因,Simpleperf 找 CPU 热点,驱动源码找最终触发条件;任何根因结论都必须回到同一对象、同一时间窗口和同一条依赖链。

weixin_43228946的博客 362

云手机私有化部署完整方案:基于ARM服务器搭建私有安卓云集群

ARM 服务器是私有化安卓云集群最优硬件底座,原生架构匹配 Android,高密度、低损耗,非常适合企业内网场景。整套私有化方案的核心,从来不是 “跑起来安卓”,而是隔离可控、可审计、可运维、可扩容。两条路线各有取舍:开源自建灵活、门槛高;商用私有化交付开箱即用、安全能力完备,是当前企业生产环境主流方案。六边云手机私有化方案,补齐了自建方案在驱动适配、管控平台、审计合规、信创适配上的短板,适合对数据主权、内网隔离有强需求的政企、自研 App、垂直行业客户。

a598652的博客 308

Android 顶点上传:Heap 到 Direct 的零拷贝,省的是 JNI 次数

一帧数十万次putFloat的性能瓶颈源于频繁跨JNI边界,每次开销远超传输字节数。通过将写入与上传解耦:用堆内ByteBuffer高速写入,最后一次性put(writeBuf)批量传至堆外DirectByteBuffer,将数百万次边界调用压缩为一次,实现近10倍性能提升。关键在于复用堆外缓冲区、统一端序,并结合“更新-绘制”分离,仅在数据变更时上传顶点,平移缩放时零开销重绘,彻底释放CPU瓶颈。

mmsx990的博客 474

Android 系统启动与调试中的日志抓取方式全解析

│ 用户操作/系统事件 ││ │▼ ▼│ (驱动/硬件/内存管理) │ │ (App/SystemServer) ││ │ │ ││ │▼ ▼│ dmesg 命令 │ │ logd daemon ││ cat /proc/kmsg │ │ (分类存储到分区) ││ │▼ ▼│ 串口 UART │ │ logcat 命令 ││ (硬件直连,最早输出) │ │ adb logcat ││ │▼│ (汇总所有日志+系统状态) │工具最佳用途关键优势主要局限dmesg。

zhaoshuzhaoshu的专栏 256
上一篇: 构造函数调用虚函数
下一篇: Android ColorFilter and Tint
小马识图
博客等级 码龄18年 8粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值