对象可见性
Objects visibility
我搜索了很多,但找不到 tools:visibility = "visible"
和 android:visibility = "visible"
之间的区别?哪种情况必须用工具还是android?
这里是简单的解释:
tools:visibility = "visible"
用于在 IDE.It 上操纵视图可见性不会影响真实视图 time.It 仅用于 Android Studio 中的设计目的
而
android:visibility = "visible"
是将在 运行 时间内执行的实际代码,并将更改您的视图
参考:http://tools.android.com/tips/layout-designtime-attributes
TOOLS 值将仅用于 Android Studio.t
中的布局预览
ANDROID 值将在应用程序中正常使用。
因此,如果您为主容器设置值:
tools:visibility:"gone"
android:visibility:"visible"
AS 中布局预览中的主容器将消失,但如果您在模拟器/设备上启动应用程序,它将可见。
如果您看到 Design Time Layout Attributes
The tools namespace is a specially recognized namespace by the Android tools, so all the attributes you define on view elements in the tools-namespace will be automatically stripped when the application is packaged and there is no runtime overhead.
因此,如果我们只需要在开发期间在布局编辑器中测试某些内容,而不会影响 运行 时间,我们可以使用 tools
命名空间。
示例:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First"
tools:visibility="invisible" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second"
tools:visibility="visible" />
如果在 Android Studio 设计器视图中呈现以上布局,第一个 Button 将不可见。但是在 运行 的时候,它将是可见的。
工具: 属性仅在编辑布局时有助于设计时预览,而
android: 实际上会影响它在实际设备上的显示方式。
确切的问题应该是
"What the difference between android:...
and tools:...
on Layout
XML files"
tools是Design Attributes之一,可以方便开发中XML布局的创建framework.This属性用来展示开发框架是什么选择 activity class 来实现布局。使用“tools:context”,Android Studio 会自动为预览选择必要的主题
Android 用于 运行-time 应用程序,当您在设备中启动您的 apk
根据here
我搜索了很多,但找不到 tools:visibility = "visible"
和 android:visibility = "visible"
之间的区别?哪种情况必须用工具还是android?
这里是简单的解释:
tools:visibility = "visible"
用于在 IDE.It 上操纵视图可见性不会影响真实视图 time.It 仅用于 Android Studio 中的设计目的
而
android:visibility = "visible"
是将在 运行 时间内执行的实际代码,并将更改您的视图
参考:http://tools.android.com/tips/layout-designtime-attributes
TOOLS 值将仅用于 Android Studio.t
中的布局预览ANDROID 值将在应用程序中正常使用。
因此,如果您为主容器设置值: tools:visibility:"gone" android:visibility:"visible"
AS 中布局预览中的主容器将消失,但如果您在模拟器/设备上启动应用程序,它将可见。
如果您看到 Design Time Layout Attributes
The tools namespace is a specially recognized namespace by the Android tools, so all the attributes you define on view elements in the tools-namespace will be automatically stripped when the application is packaged and there is no runtime overhead.
因此,如果我们只需要在开发期间在布局编辑器中测试某些内容,而不会影响 运行 时间,我们可以使用 tools
命名空间。
示例:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First"
tools:visibility="invisible" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second"
tools:visibility="visible" />
如果在 Android Studio 设计器视图中呈现以上布局,第一个 Button 将不可见。但是在 运行 的时候,它将是可见的。
工具: 属性仅在编辑布局时有助于设计时预览,而
android: 实际上会影响它在实际设备上的显示方式。
确切的问题应该是
"What the difference between
android:...
andtools:...
on Layout XML files"
tools是Design Attributes之一,可以方便开发中XML布局的创建framework.This属性用来展示开发框架是什么选择 activity class 来实现布局。使用“tools:context”,Android Studio 会自动为预览选择必要的主题
Android 用于 运行-time 应用程序,当您在设备中启动您的 apk
根据here