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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Android multiple layout directory considered harmful

1 点作者 pocorall超过 12 年前

1 comment

Zigurd超过 12 年前
The answer for buttons in multiple layouts is to factor out common parts of a layout. That is, before adding a button to several layout files, find the big chunks of layout shared by multiple variants and create a single layout file for each significant chunk.<p>Now you have one place to modify.<p>What's REALLY harmful is code that goes like this:<p>if (portrait) orientation = VERTICAL<p>That is guaranteed to be wrong on some device. The road to that inner ring of hell where testing on dozens of devices is a vain quest for "good" code that makes decisions about layout is paved with code like this.<p>But if you let the Android system choose among layout files, the chances for a pathological decision about layout are greatly reduced.