All Products
Search
Document Center

Customize rendering parameters in custom View

Last Updated: Jul 16, 2021

In Android Mini Program, the rendering parameter customization function of custom View is only supported in mPaaS 10.1.68.29 and later versions. If the current baseline version is lower than 10.1.68.29, please refer to mPaaS Upgrade Guide to upgrade the baseline version to 10.1.68.29.

Add custom rendering parameters in the tab of mini program

 
  1. <mpaas-component
  2. id="mpaas-map"
  3. type="custom_map"
  4. style="{{ width: 200, height: 200 }}"
  5. color="#FFFF00FF"
  6. ···
  7. />
Note:
  • color is a custom rendering parameter, which can be named arbitrarily. But the name of the custom rendering parameter cannot start with ‘on’, and the type cannot be func.
  • id, type, and style are the default fields, please do not use these fields as custom rendering parameters of custom views.

Receive and render custom rendering parameters

The client rewrites onReceivedRender to receive the rendering parameters from the mini program, and calls Android View to render the parameters.

 
  1. public class MyTestEmbedView extends MPBaseEmbedView {
  2. ···
  3. @Override
  4. public void onReceivedRender(JSONObject jsonObject, H5BridgeContext h5BridgeContext) {
  5. LoggerFactory.getTraceLogger().debug(TAG, "onReceivedRender: " + jsonObject.toString());
  6. mRealView.render(jsonObject);
  7. }
  8. ···
  9. }