react-native-navigation的迁移库

ExternalComponentLayout.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.reactnativenavigation.views;
  2. import android.annotation.SuppressLint;
  3. import android.content.Context;
  4. import android.widget.FrameLayout;
  5. import android.widget.RelativeLayout;
  6. import com.reactnativenavigation.views.topbar.TopBar;
  7. import static android.widget.RelativeLayout.BELOW;
  8. @SuppressLint("ViewConstructor")
  9. public class ExternalComponentLayout extends FrameLayout implements Component {
  10. public ExternalComponentLayout(Context context) {
  11. super(context);
  12. setContentDescription("ExternalComponentLayout");
  13. }
  14. @Override
  15. public void drawBehindTopBar() {
  16. if (getParent() instanceof RelativeLayout) {
  17. RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
  18. layoutParams.removeRule(BELOW);
  19. setLayoutParams(layoutParams);
  20. }
  21. }
  22. @Override
  23. public void drawBelowTopBar(TopBar topBar) {
  24. if (getParent() instanceof RelativeLayout) {
  25. RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
  26. layoutParams.addRule(BELOW, topBar.getId());
  27. setLayoutParams(layoutParams);
  28. }
  29. }
  30. @Override
  31. public boolean isRendered() {
  32. return getChildCount() >= 1;
  33. }
  34. }