android XML UI 布局的参考在哪里?
我正在寻找 Android UI 中通常附带的各种 XML 布局属性设置的所有可能选项的规范或参考。谷歌似乎很擅长埋葬它。这类似于这个问题,但仍然没有得到有效回答。
例如,对于 TextView layout_width 定义,我可以使用哪些选项?必须有一个完整的定义发布......某处......
I am looking for a spec or reference of all the possible options for the various XML layout attribute settings that typically come with an android UI. Google seem to be good at burying it. This is similar to this question but remains in-effectively answered.
Such as what are my options available to me for the TextView layout_width definition ? There must be a complete definition published ... somehwere....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
layout_*
属性并不是它们所出现的视图的直接一部分,这就是为什么您在 TextView 的文档中找不到它们的原因。 (TextView 不是 ViewGroup。)它们是父视图的参数,也称为布局参数
。查看链接页面顶部的“已知子类”部分,获取其中的列表。它们是关于如何ViewGroup
的说明应该安排每个子视图,并且每个父类型可以根据其支持的布局选项类型识别不同的子视图。例如,
LinearLayout.LayoutParams
支持android:layout_weight
参数。 LinearLayout 的子级可以指定权重,以在测量完所有子级后请求剩余空间的比例。您可以为两个基本宽度为 0 的同级 TextView 赋予相同的权重,以便为它们提供父级中各一半的可用空间。layout_*
attributes aren't directly part of the view they appear on, which is why you won't find them in TextView's documentation. (TextView is not a ViewGroup.) They are arguments to the parent view, also known asLayoutParams
. Take a look at the "Known Subclasses" sections at the top of the linked page for a list of them. They're instructions about how aViewGroup
should arrange each child view, and each parent type can recognize different ones depending on what kinds of layout options it supports.For example,
LinearLayout.LayoutParams
supports theandroid:layout_weight
parameter. Children of aLinearLayout
can specify weight to request a proportion of the remaining space after all children have been measured. You can give equal weight to two sibling TextViews with a base width of 0 to give them each half of the available space within the parent.通常 developer.android.com 是您的网站。也许这有帮助:
http://developer.android.com/reference/android/view/View.html
如果您使用 Eclipse,那么自动完成建议也可以帮助您添加正确的参数。
...layout_width 的选项有
Normally developer.android.com is your site. Maybe this helps:
http://developer.android.com/reference/android/view/View.html
If you use Eclipse, then the autocomplete suggestions may help you as well in adding the right parameter.
...and the options you have for layout_width are
ViewGroup.LayoutParams 的文档中对布局参数进行了很好的描述及其子类。对于真正内心强大的人,您可以随时浏览 attr.xml 的源。
Layout parameters are pretty well described in the documentation for ViewGroup.LayoutParams and its subclasses. For the truly strong of heart, you can always browse the source for attr.xml.