-3
我有一個共同的LinearLayout,我想將其放入其自己的佈局文件。它將用於在不同的佈局文件中環繞不同的視圖。是否有可能在視圖中包裝一個包含(或實現類似效果)?包裝包括視圖
我有一個共同的LinearLayout,我想將其放入其自己的佈局文件。它將用於在不同的佈局文件中環繞不同的視圖。是否有可能在視圖中包裝一個包含(或實現類似效果)?包裝包括視圖
I have a common LinearLayout that I want to put into its own layout file
放置LinearLayout
在一個單獨的佈局文件。膨脹此佈局文件:
View mLinearLayoutView = getLayoutInflater().inflate(R.layout.linear_layout, null);
LinearLayout ll = (LinearLayout) mLinearLayoutView.findViewById(R.id.my_linear_layout);
// Inflate the view you want to include within the LinearLayout
View mChildView = getLayoutInflater().inflate(R.layout.any_other_child_view, null);
// Initialize/setup any child components
ll.addView(mChildView); // Or, ll.addView(mChildView, optional_layout_parameters);
setContentView(mLinearLayoutView);
LinearLayout究竟有什麼不同?它是以某種方式設計的嗎? – Karakuri
@Karakuri最重要的是我想在自己的文件中有一個自定義佈局,然後用它來環繞不同的視圖,但對於include來說似乎不可能。 – btse
我不認爲有重新使用父佈局的'wrap'功能。 –