加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml tools属性详解

发布时间:2020-12-16 08:42:59 所属栏目:百科 来源:网络整理
导读:ListView在预览图中通常是这样的。 我们在java代码中添加的header以及listItem无法预览到。 tools设置 ListView tools:listheader = "@layout/header_view" tools:listitem = "@layout/listview_item" android:id = "@+id/list_view" android:layout_width =

ListView在预览图中通常是这样的。


我们在java代码中添加的header以及listItem无法预览到。

tools设置

<ListView  tools:listheader="@layout/header_view" tools:listitem="@layout/listview_item" android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="match_parent"></ListView>

Fragment通常是这样的。


tools设置

<fragment
        tools:layout="@layout/fragment_content_2"
        android:id="@+id/title_area"
      android:name="com.viktor.androidstudydemo.uiComponent.fragment.TitleFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

命名空间

xmlns:tools=”http://schemas.android.com/tools”

tools是只给IDE预览用的

tools可以告诉Android Studio,哪些属性在运行的时候是被忽略的,只在设计布局的时候有效。tools可以覆盖android的所有标准属性,将android:换成tools:即可。同时在运行的时候就连tools:本身都是被忽略的,不会被带进apk中。

更多参考

http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0309/2567.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读