TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Anko – Pleasant Android development in Kotlin

158 点作者 ericweyant大约 10 年前

12 条评论

jarofgreen大约 10 年前
&gt; XML is parsed on the device wasting CPU time and battery<p>It was my understanding the XML was compiled into a binary format for faster parsing on device, am I wrong on that?<p>EDIT: <a href="http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Android_application_package" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Android_application_package</a> &quot;resources.arsc: a file containing precompiled resources, such as binary XML for example.&quot; Ah yes, I think it does.<p>&gt; Most of all, it allows no code reuse.<p>If we are talking code reuse in terms of having one common bit of layout that is used across several different layouts, actually you can: <a href="http:&#x2F;&#x2F;developer.android.com&#x2F;training&#x2F;improving-layouts&#x2F;reusing-layouts.html" rel="nofollow">http:&#x2F;&#x2F;developer.android.com&#x2F;training&#x2F;improving-layouts&#x2F;reus...</a><p>Also, the Android view system as it stands is incredible flexible.<p>You can provide different layouts and style rules for different screensizes and device configs - an kinda equivalent to the webs responsive design using CSS media queries.<p>Also, every view component is just a Java class. As well as allowing you to create your own class from scratch that you can just use as part of a view, you can also extend an existing view class and just change one bit of it&#x27;s behaviour.<p>I don&#x27;t especially mean to have a go at Anko - sorry. It&#x27;s just that I think the Android views are actually pretty good, and certainly when I&#x27;m working on Android apps this isn&#x27;t one of the major problems I have!
评论 #9521078 未加载
评论 #9520632 未加载
评论 #9520591 未加载
评论 #9520258 未加载
m_fayer大约 10 年前
After a quick skim this seems great, but just one piece of a much bigger puzzle. Android activities, regardless of whether the view is constructed declaratively or in code, seem to always become an untestable mess that does way too much. At least, that&#x27;s what happens if activities are used as intended. IMO, the bare minimum necessary to fix this is some more elegant alternative to AXML that, crucially, has some kind of declarative databinding support. Roll that into Anko and we&#x27;re on our way to taming the activity.
评论 #9519876 未加载
评论 #9523356 未加载
burntcookie90大约 10 年前
I have a relatively medium implementation of a layout in anko here: <a href="https:&#x2F;&#x2F;github.com&#x2F;burntcookie90&#x2F;KotMeh&#x2F;blob&#x2F;master&#x2F;app&#x2F;src&#x2F;main&#x2F;kotlin&#x2F;io&#x2F;dwak&#x2F;meh&#x2F;view&#x2F;MainActivity.kt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;burntcookie90&#x2F;KotMeh&#x2F;blob&#x2F;master&#x2F;app&#x2F;src&#x2F;...</a><p>I&#x27;m not sold on using it as a layout DSL, it&#x27;s just not as easy to format as XML, and I don&#x27;t think it looks syntactically <i>that</i> much better. However, I am sold on using anko as replacement for setters and getters (ie. `setText(&quot;test&quot;)` is just `.text = &quot;test&quot;`). Additionally, it&#x27;s incredibly easy to add more extensions for other view types, like `RecyclerView` and custom layouts.
spbaar大约 10 年前
What does it even mean for an XML layout to be type and null safe? This reads like a parody. XML resources give you orientation&#x2F;screen size resolution and component re use. I haven&#x27;t drunk the MVP kool aid that&#x27;s the new hotness, but this is far too much in the other direction. If you&#x27;re setting margins in code you&#x27;re probably doing something wrong.
评论 #9520450 未加载
评论 #9520380 未加载
EddieRingle大约 10 年前
I&#x27;ve been using this since it was still a side project by yanex under the name of Koan. I&#x27;ll never go back to writing XML layouts.
评论 #9520455 未加载
stevebot大约 10 年前
This is great, and looks so much easier (as does Scaloid), but I have never found a commercial project that I can use it on. #1 by choosing Anko or Scaloid you are isolating future developers to only those familiar to Anko or Scaloid OR those willing to learn (as well as the fact that Scaloid doesn&#x27;t sell very well on resumes IMO; my guess is the same for Anko).<p>It&#x27;s a dilemma, as Java+XML is very verbose. still, with the amount of work Android Studio does, I&#x27;m not sure its a big problem for most of us Android Developers.
评论 #9520757 未加载
da4c30ff大约 10 年前
What about layout versions for different screen-sizes, orientations, etc.?
评论 #9520385 未加载
nbrempel大约 10 年前
I&#x27;ve had my eye on Kotlin for a while. I&#x27;m looking forward to seeing where this goes!
评论 #9521520 未加载
frik大约 10 年前
Kotlin: <a href="http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Kotlin_(programming_language)" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Kotlin_(programming_language)</a>
harunurhan大约 10 年前
I think a detailed performance comparison should be provided to be more transparent and to make developers start using Anko. I mean I want to see how it differs in terms of app opening time, apk size, loading another view in app time etc.
karmakaze大约 10 年前
Nice job. With the advent of Swift, mobile developers may benefit from something in a sweet spot between Java and Scala. Looking forward to testing this out and further developments.
ekianjo大约 10 年前
Using Japanese common words for projects is becoming almost cliche these days among software developers. What&#x27;s next, Kuruma ? Madoguchi ? Unko ?
评论 #9522257 未加载