有没有一种方法可以将通过编程创建的 Viewgroup “转换”为 parcelable,然后通过和aidl 发送这个 ViewGroup?
我知道这可能不是一个好的设计或性能,但有没有办法我可以做到这一点?
这就是我的 ViewGroup 的创建方式:
public ViewGroup getViewGroup(){
LinearLayout root = new LinearLayout(getContext());
root.setPadding(getValueinPixels(16),getValueinPixels(16),getValueinPixels(16),getValueinPixels(16));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
root.setLayoutParams(params);
root.setOrientation(LinearLayout.VERTICAL);
TextView message = new TextView(getContext());
message.setText(getMessageCorrespondentToAction());
message.setTextColor(Color.parseColor(getHexadecimalColorOfMessageView()));
message.setPadding(getValueinPixels(0),getValueinPixels(8),getValueinPixels(0),getValueinPixels(8));
TextView action = new TextView(getContext());
action.setTextColor(Color.parseColor(getHexadecimalColorOfActionView()));
action.setPadding(getValueinPixels(0),getValueinPixels(8),getValueinPixels(0),getValueinPixels(8));
root.addView(message);
root.addView(action);
return root;
}