android 中 FrameLayout 的更好方法?
better approach for FrameLayout in android?
我在我的项目中使用 frameLayout.. 但是我在 android 开发中完全混淆了如果我使用 xml 文件作为静态方法而另一方面我使用 java frameLayout( 或任何 android 功能)的 运行 时间行为代码,从用户体验的角度来看,这种方法对我的项目有好处。
请仅提供您的直截了当的观点和理由..
提前谢谢。
which approach is good for my project
首先,只有你自己知道什么对你的项目有好处,但是文档https://developer.android.com/guide/topics/ui/declaring-layout.html给出了一些建议,我同意:
The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems.
在 XML 中定义接口在大多数情况下是更好的方法。
as user-experience point of view
无论在Java或XML中定义UI,用户体验都是一样的,毕竟界面是一样的。
这与之前提出的问题类似。
在 XML 中声明 UI 个元素。 Android 提供了一个直接的 XML 词汇表,对应于视图 类 和子 类,例如用于小部件和布局的词汇表。
在运行时实例化布局元素。您的应用程序可以通过编程方式创建 View 和 ViewGroup 对象(并操作它们的属性)。
The advantage to declaring your UI in XML is that it enables you to better separate the
presentation of your application from the code that controls its behavior. Your UI descriptions are
external to your application code, which means that you can modify or adapt it without having to
modify your source code and recompile. For example, you can create XML layouts for different screen
orientations, different device screen sizes, and different languages. Additionally, declaring the
layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug
problems.
当您编译您的应用程序时,每个 XML 布局文件都被编译成一个视图资源。您应该在 Activity.onCreate() 回调实现中从您的应用程序代码加载布局资源。通过调用 setContentView() 并将对布局资源的引用传递给它来实现。
请访问以获取对 http://developer.android.com/guide/topics/ui/declaring-layout.html
的更多参考
我在我的项目中使用 frameLayout.. 但是我在 android 开发中完全混淆了如果我使用 xml 文件作为静态方法而另一方面我使用 java frameLayout( 或任何 android 功能)的 运行 时间行为代码,从用户体验的角度来看,这种方法对我的项目有好处。 请仅提供您的直截了当的观点和理由.. 提前谢谢。
which approach is good for my project
首先,只有你自己知道什么对你的项目有好处,但是文档https://developer.android.com/guide/topics/ui/declaring-layout.html给出了一些建议,我同意:
The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems.
在 XML 中定义接口在大多数情况下是更好的方法。
as user-experience point of view
无论在Java或XML中定义UI,用户体验都是一样的,毕竟界面是一样的。
这与之前提出的问题类似。
在 XML 中声明 UI 个元素。 Android 提供了一个直接的 XML 词汇表,对应于视图 类 和子 类,例如用于小部件和布局的词汇表。 在运行时实例化布局元素。您的应用程序可以通过编程方式创建 View 和 ViewGroup 对象(并操作它们的属性)。
The advantage to declaring your UI in XML is that it enables you to better separate the
presentation of your application from the code that controls its behavior. Your UI descriptions are
external to your application code, which means that you can modify or adapt it without having to
modify your source code and recompile. For example, you can create XML layouts for different screen
orientations, different device screen sizes, and different languages. Additionally, declaring the
layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug
problems.
当您编译您的应用程序时,每个 XML 布局文件都被编译成一个视图资源。您应该在 Activity.onCreate() 回调实现中从您的应用程序代码加载布局资源。通过调用 setContentView() 并将对布局资源的引用传递给它来实现。
请访问以获取对 http://developer.android.com/guide/topics/ui/declaring-layout.html
的更多参考