pst*_*ton 4 xml android android-layout
我已经完成了一些教程等,并且发现我可以在代码中实现定义所有UI组件的相同结果.
例如:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("hello");
LinearLayout ll = new LinearLayout(this);
ll.addView(tv);
setContentView(ll);
}
Run Code Online (Sandbox Code Playgroud)
相当于
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
Run Code Online (Sandbox Code Playgroud)
+
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
Run Code Online (Sandbox Code Playgroud)
为此使用XML有哪些性能/可维护性优势?
如果程序员喜欢使用基于XML的代码,还应该考虑哪些额外的考虑因素?
为此使用XML有哪些可维护性优势?
为此使用XML有哪些性能优势?
这一切都取决于我想的实施.我怀疑是否有任何可观的性能差异,但老实说,我不知道该如何明确地说出它们可能是什么.