Where is a reference to the android XML UI layout?

发布于 2022-09-06 12:33:17 字数 507 浏览 19 评论 0

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泡沫很甜 2022-09-13 12:33:17

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 as LayoutParams. 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 a ViewGroup 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 the android:layout_weight parameter. Children of a LinearLayout 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.

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Hello" />
    <TextView android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="World" />
</LinearLayout>
旧人 2022-09-13 12:33:17

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

  • wrap_content (as large as the content of the View)
  • fill_parent (extends to the whole size - width or height - of its parent)
意中人 2022-09-13 12:33:17

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文