Example #1
1
  private void setPosition(View v, int dx, int dy) {
    int parentWidth = this.getWidth();
    int parentHeight = this.getHeight();
    int l = v.getLeft() + dx;
    int t = v.getTop() + dy;

    if (l < 0) {
      l = 0;
    } else if ((l + v.getWidth()) >= parentWidth) {
      l = parentWidth - v.getWidth();
    }

    if (t < 0) {
      t = 0;
    } else if ((t + v.getHeight()) >= parentHeight) {
      t = parentHeight - v.getHeight();
    }

    int r = l + v.getWidth();
    int b = t + v.getHeight();

    v.layout(l, t, r, b);

    RelativeLayout.LayoutParams params =
        (android.widget.RelativeLayout.LayoutParams) v.getLayoutParams();
    params.leftMargin = l;
    params.topMargin = t;
    v.setLayoutParams(params);
  }
Example #2
1
  public void onClick(View v, int position, int countitem) {
    ImageView selectedShip = ((MapBuilder) context).getSelectedShip();
    if (selectedShip != null) {
      ShipOnMap som = new ShipOnMap();
      RelativeLayout fl = (RelativeLayout) v;
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(selectedShip.getWidth(), selectedShip.getHeight());
      som.start.x = x;
      som.start.y = y - v.getTop();
      som.time = (countitem - 1 - position) * 3 + 1;
      String[] shipinfo = ((String) selectedShip.getTag()).split(":");
      som.type = shipinfo[0];
      som.weapon = shipinfo[1];
      params.leftMargin = x - (selectedShip.getWidth() / 2);
      params.topMargin = y - v.getTop() - (selectedShip.getHeight() / 2);
      ImageView iv = new ImageView(context);
      iv.setImageDrawable(selectedShip.getDrawable());
      int h = fl.getHeight();
      int w = fl.getWidth();
      if (!ship.containsKey(position)) {
        ship.put(position, new LinkedList<ShipOnMap>());
      }

      som.ship = iv.getDrawable();
      som.param = params;
      List<ShipOnMap> lship = ship.get(position);
      lship.add(som);
      iv.setTag(position + "/" + (lship.size() - 1));
      ((MapBuilder) context).registerForContextMenu(iv);
      fl.addView(iv, params);
      fl.getLayoutParams().height = h;
      fl.getLayoutParams().width = w;
    }
  }
Example #3
0
  private void moveZoomedView(
      ImmutableViewportMetrics metrics,
      float newLeftMargin,
      float newTopMargin,
      StartPointUpdate animateStartPoint) {
    RelativeLayout.LayoutParams newLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
    newLayoutParams.leftMargin = (int) newLeftMargin;
    newLayoutParams.topMargin = (int) newTopMargin;
    int topMarginMin = (int) (layerView.getSurfaceTranslation() + dynamicToolbarOverlap);
    int topMarginMax = layerView.getHeight() - viewContainerHeight;
    int leftMarginMin = 0;
    int leftMarginMax = layerView.getWidth() - viewContainerWidth;

    if (newTopMargin < topMarginMin) {
      newLayoutParams.topMargin = topMarginMin;
    } else if (newTopMargin > topMarginMax) {
      newLayoutParams.topMargin = topMarginMax;
    }

    if (newLeftMargin < leftMarginMin) {
      newLayoutParams.leftMargin = leftMarginMin;
    } else if (newLeftMargin > leftMarginMax) {
      newLayoutParams.leftMargin = leftMarginMax;
    }

    if (newLayoutParams.topMargin < topMarginMin + 1) {
      moveToolbar(false);
    } else if (newLayoutParams.topMargin > topMarginMax - 1) {
      moveToolbar(true);
    }

    if (animateStartPoint == StartPointUpdate.GECKO_POSITION) {
      // Before this point, the animationStart point is relative to the layerView.
      // The value is initialized in startZoomDisplay using the click point position coming from
      // Gecko.
      // The position of the zoomed view is now calculated, so the position of the animation
      // can now be correctly set relative to the zoomed view
      animationStart.x = animationStart.x - newLayoutParams.leftMargin;
      animationStart.y = animationStart.y - newLayoutParams.topMargin;
    } else if (animateStartPoint == StartPointUpdate.CENTER) {
      // At this point, the animationStart point is no more valid probably because
      // the zoomed view has been moved by the user.
      // In this case, the animationStart point is set to the center point of the zoomed view.
      PointF convertedPosition =
          getUnzoomedPositionFromPointInZoomedView(viewContainerWidth / 2, viewContainerHeight / 2);
      animationStart.x = convertedPosition.x - newLayoutParams.leftMargin;
      animationStart.y = convertedPosition.y - newLayoutParams.topMargin;
    }

    setLayoutParams(newLayoutParams);
    PointF convertedPosition =
        getUnzoomedPositionFromPointInZoomedView(0, offsetDueToToolBarPosition);
    lastPosition = PointUtils.round(convertedPosition);
    requestZoomedViewRender();
  }
 private void moveView(int x, int y) {
   if (touchView == null) return;
   RelativeLayout.LayoutParams params =
       new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   params.leftMargin = x - startX + startTouchViewLeft;
   params.topMargin = y - startY + startTouchViewTop;
   // 限制子控件移动必须在视图范围内
   if (params.leftMargin < 0 || (params.leftMargin + touchView.getWidth()) > getWidth())
     params.leftMargin = touchView.getLeft();
   if (params.topMargin < 0 || (params.topMargin + touchView.getHeight()) > getHeight())
     params.topMargin = touchView.getTop();
   touchView.setLayoutParams(params);
 }
Example #5
0
  public void setSelected(int newState) {
    RelativeLayout.LayoutParams lp =
        (RelativeLayout.LayoutParams) mToggleSelector.getLayoutParams();
    lp.topMargin = (mTableLayout.getMeasuredHeight() - heightItem) / 2;
    lp.leftMargin = newState * widthItem + mTableLayout.getPaddingLeft();
    mToggleSelector.setLayoutParams(lp);

    if (Build.VERSION.SDK_INT < 11) {
      AlphaAnimation animation = new AlphaAnimation((float) 0.2, (float) 0.2);
      animation.setDuration(0);
      animation.setFillAfter(true);
      for (ImageView view : buttonList) {
        view.startAnimation(animation);
      }
      currentState = newState;
      animation = new AlphaAnimation(1, 1);
      animation.setDuration(0);
      animation.setFillAfter(true);
      buttonList.get(currentState).startAnimation(animation);
    } else {
      for (ImageView view : buttonList) {
        view.setAlpha((float) 0.2);
      }
      currentState = newState;
      buttonList.get(currentState).setAlpha((float) 1);
    }
  }
Example #6
0
  private RelativeLayout getPageView() {
    rlPage = new RelativeLayout(getContext());
    rlPage.setBackgroundDrawable(background);
    if (dialogMode) {
      RelativeLayout rlDialog = new RelativeLayout(getContext());
      rlDialog.setBackgroundColor(0xc0323232);
      int dp_8 = dipToPx(getContext(), 8);
      int width = getScreenWidth(getContext()) - dp_8 * 2;
      RelativeLayout.LayoutParams lpDialog =
          new RelativeLayout.LayoutParams(width, LayoutParams.WRAP_CONTENT);
      lpDialog.topMargin = dp_8;
      lpDialog.bottomMargin = dp_8;
      lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlDialog.setLayoutParams(lpDialog);
      rlPage.addView(rlDialog);

      rlDialog.addView(getPageTitle());
      rlDialog.addView(getPageBody());
      rlDialog.addView(getImagePin());
    } else {
      rlPage.addView(getPageTitle());
      rlPage.addView(getPageBody());
      rlPage.addView(getImagePin());
    }
    return rlPage;
  }
  public void displayAjustView(RecyclingBitmapDrawable value) {
    if (value != null && value.getBitmap() != null) {
      this.value = value;
      adjustView =
          new AdjustView(
              context, value.getBitmap().getWidth(), value.getBitmap().getHeight(), value);
      adjustView.setBackgroundColor(Color.TRANSPARENT);
      //			adjustView.setImageBitmap(bitmap);

      relayout.removeAllViews();
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);

      Tools.initWidth = value.getBitmap().getWidth();
      Tools.initHeight = value.getBitmap().getHeight();

      params.topMargin = (int) (screenHeight * 0.5 - value.getBitmap().getHeight() * 0.5);
      params.leftMargin = (int) (screenWidth * 0.5 - value.getBitmap().getWidth() * 0.5);
      relayout.addView(adjustView, params);

      float rate = (float) viewWidth / viewHeight;
      int mheight = (int) (value.getBitmap().getHeight() * 0.5);
      int mwidth = (int) (mheight * rate);

      adjustView.auto_setAdjustImg(0, 0, mwidth, mheight);
    } else relayout.removeAllViews();
  }
 public void drawAnnotations() {
   mAnnotationLabelOverlay.removeAllViews();
   if (mQueryResult == null) {
     return;
   }
   int[] actImageRect = getBitmapPositionInsideImageView(mImageView);
   List<Annotation> annotations = mQueryResult.annotations;
   int index = -1;
   for (Annotation anno : annotations) {
     index++;
     LabelView label = new LabelView(getActivity());
     label.mLabelText.setVisibility(View.VISIBLE);
     label.mLabelText.setText(anno.text);
     label.mPosition = index;
     float padding = 100;
     float cx = anno.getCenterX() * actImageRect[2];
     float cy = anno.getCenterY() * actImageRect[3];
     if (cx > actImageRect[2] - padding) {
       cx = actImageRect[2] - padding + randomInt(-30, 30);
     } else if (cx < padding) {
       cx = padding + randomInt(-30, 30);
     }
     if (cy > actImageRect[3] - padding) {
       cy = actImageRect[3] - padding + randomInt(-30, 30);
     } else if (cy < padding) {
       cy = padding + randomInt(-30, 30);
     }
     RelativeLayout.LayoutParams params =
         new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
     params.leftMargin = (int) cx + actImageRect[0];
     params.topMargin = (int) cy + actImageRect[1];
     mAnnotationLabelOverlay.addView(label, params);
     label.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             LabelView view = (LabelView) v;
             Log.d("label position: ", "" + view.mPosition);
             int position = view.mPosition;
             if (position >= 0 && position < mAnnotationList.size()) {
               mLinearLayoutManager.scrollToPosition(position);
             }
             //                    String text = view.mLabelText.getText().toString();
             //                    AnnotationDetailFragment fragment = new
             // AnnotationDetailFragment();
             //                    Bundle args = new Bundle();
             //                    args.putString("annotation_text", text);
             //                    fragment.setArguments(args);
             //
             // getFragmentManager().beginTransaction().replace(R.id.frame_container,
             // fragment).addToBackStack(null).commit();
           }
         });
     if (mLabels == null) {
       mLabels = new ArrayList<>();
     }
     mLabels.add(label);
   }
 }
  private void initView(View layout) {
    lamp = layout.findViewById(R.id.v_lamp);
    menuLv = (ListView) layout.findViewById(R.id.lv_menu);
    subjectLv = (ListView) layout.findViewById(R.id.lv_subject);
    foldBtn = layout.findViewById(R.id.ll_title_sp);
    foldContent = layout.findViewById(R.id.ll_lv_sp);
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) foldBtn.getLayoutParams();
    lp.leftMargin = location[0];
    lp.topMargin = location[1];
    foldBtn.setLayoutParams(lp);
    foldBtn.setOnClickListener(this);
    lamp.setOnClickListener(this);
    menuAdapter = new DataAdapter(getActivity().getBaseContext());

    menuAdapter.setData(allocateData());
    menuLv.setAdapter(menuAdapter);
    menuLv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            menuAdapter.checked(i);
            subjectAdapter.setData(allocateSubject());
            subjectAdapter.notifyDataSetChanged();
          }
        });
    subjectAdapter = new DataAdapter(getActivity().getBaseContext());
    subjectAdapter.checked(-1);
    subjectAdapter.setData(allocateSubject());
    subjectLv.setAdapter(subjectAdapter);
  }
  private void setLinePositions(GridLayoutView glv) {

    // extend imgageView to bounds
    Bitmap bitmapy = BitmapFactory.decodeResource(getResources(), R.drawable.line_y);
    bitmapy = Bitmap.createScaledBitmap(bitmapy, glWidth, bitmapy.getHeight(), true);
    lineY.setImageBitmap(bitmapy);

    Bitmap bitmapx = BitmapFactory.decodeResource(getResources(), R.drawable.line_x);
    bitmapx = Bitmap.createScaledBitmap(bitmapx, bitmapx.getWidth(), glHeight, true);
    lineX.setImageBitmap(bitmapx);

    xParams = (RelativeLayout.LayoutParams) lineX.getLayoutParams();
    yParams = (RelativeLayout.LayoutParams) lineY.getLayoutParams();

    int positionLineXCentre = glv.getAxisXlines().get(glv.getGridSize() / 2).x;
    xParams.leftMargin =
        shapeStartPointX(glv.getZeroPosX(), glv.getLineSpacingX(), lineStartCoordX)
            - bitmapx.getWidth() / 2;
    lineX.setLayoutParams(xParams);

    int positionLineYCentre = glv.getAxisYlines().get(glv.getGridSize() / 2).y;
    yParams.topMargin =
        shapeStartPointY(glv.getZeroPosY(), glv.getLineSpacingY(), lineStartCoordY)
            - bitmapy.getHeight() / 2;
    lineY.setLayoutParams(yParams);
  }
Example #11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // Open app in fullscreen mode
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    noteLayout = (RelativeLayout) findViewById(R.id.notePanel);

    canvasView = new CanvasView(this);
    switchy = new Switch(this);
    switchy = (Switch) findViewById(R.id.switch1);
    switchy.setOnCheckedChangeListener(this);

    inkRegion = new ArrayList<InkRegion>();
    inkRegion.add(new InkRegion(this, 0));
    inkRegion.add(new InkRegion(this, 1));
    inkRegion.get(0).setBackgroundColor(Color.YELLOW);
    inkRegion.get(1).setBackgroundColor(Color.CYAN);

    // noteLayout.addView(canvasView);
    noteLayout.addView(canvasView);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(200, 200);
    params.leftMargin = 300;
    params.topMargin = 200;
    inkRegion.get(0).setBackgroundColor(Color.GREEN);
    inkRegion.get(0).setPivotX(0);
    inkRegion.get(0).setPivotY(0);
    inkRegion.get(0).setRotation(45);
    inkRegion.get(0).setScaleX((float) 0.2);
    inkRegion.get(0).setScaleY((float) 0.3);
    noteLayout.addView(inkRegion.get(0), params);

    RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(200, 200);
    params1.leftMargin = 300;
    params1.topMargin = 200;
    inkRegion.get(1).setBackgroundColor(Color.BLUE);
    inkRegion.get(1).setPivotX(0);
    inkRegion.get(1).setPivotY(0);
    inkRegion.get(1).setRotation(90);
    inkRegion.get(1).setScaleX((float) 0.2);
    inkRegion.get(1).setScaleY((float) 0.2);
    noteLayout.addView(inkRegion.get(1), params1);
  }
 /**
  * 添加标签项
  *
  * @param x
  * @param y
  */
 private void addItem(int x, int y) {
   view = null;
   RelativeLayout.LayoutParams params =
       new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   if (x > getWidth() * 0.5) {
     params.leftMargin = x - PictureTagView.getViewWidth();
     view = new PictureTagView(getContext(), Direction.Right);
   } else {
     params.leftMargin = x;
     view = new PictureTagView(getContext(), Direction.Left);
   }
   params.topMargin = y;
   // 上下位置在视图内
   if (params.topMargin < 0) params.topMargin = 0;
   else if ((params.topMargin + PictureTagView.getViewHeight()) > getHeight())
     params.topMargin = getHeight() - PictureTagView.getViewHeight();
   this.addView(view, params);
 }
 public void setY(float y) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     super.setY(y);
   } else {
     RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
     params.topMargin = (int) y;
     setLayoutParams(params);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_measure_reaction);

    arrowImageView = (ImageView) findViewById(R.id.arrowImageView);
    timeCounterTextView = (TextView) findViewById(R.id.timeCounterTextView);
    LinearLayout cameraPreviewLinLayout = (LinearLayout) findViewById(R.id.cameraPreviewLinLayout);

    secondsLeft = 5;
    timeCounterTextView.setText(String.valueOf(secondsLeft));

    dbTopValue =
        getSharedPreferences(Constants.SHARED_PREF_FILENAME, Context.MODE_PRIVATE)
            .getInt(Constants.SHARED_PREF_TOP_DB_VALUE, -1);
    isDbLevelReached = false;
    lastMeterDegree = 0f;
    moveMeterArrow(lastMeterDegree);

    soundLevelValue = new int[7];
    isApplicationInterrupted = false;

    // Create our Preview view and set it as the content of our activity.
    preview = new CameraPreview(this);
    List<Camera.Size> tmpList = preview.getCamera().getParameters().getSupportedPreviewSizes();
    RelativeLayout.LayoutParams cameraLP =
        (RelativeLayout.LayoutParams) cameraPreviewLinLayout.getLayoutParams();
    int maxWidthResolution = tmpList.get(0).width;
    int maxHeightResolution = tmpList.get(0).height;

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int screenWidth = metrics.widthPixels;
    int screenHeight = metrics.heightPixels;

    // calculation of the best height and shift to the left
    float scale = (float) screenHeight / (float) maxHeightResolution;
    cameraLP.height = (int) (maxHeightResolution * scale);
    cameraLP.width = (int) (maxWidthResolution * scale);
    // shift to the left (center camera)
    int halfScreenWidth = screenWidth / 2;
    int shiftPx = cameraLP.width - halfScreenWidth;
    int leftShiftPx = shiftPx / 2; // make right and left invisible area equal size

    cameraLP.leftMargin = (leftShiftPx * -1);

    cameraPreviewLinLayout.setLayoutParams(cameraLP);
    cameraPreviewLinLayout.addView(preview); // add camera

    // center time counter
    RelativeLayout.LayoutParams counterLP =
        (RelativeLayout.LayoutParams) timeCounterTextView.getLayoutParams();
    counterLP.topMargin = (screenHeight / 10) - (counterLP.height / 2);
    counterLP.leftMargin = (screenWidth / 4) - (counterLP.width / 2);
  }
 private void a(int paramInt1, int paramInt2, int paramInt3)
 {
   float f1 = q().getDisplayMetrics().density;
   RelativeLayout.LayoutParams localLayoutParams = (RelativeLayout.LayoutParams)this.as.getLayoutParams();
   localLayoutParams.topMargin = (int)(0.5F + f1 * paramInt1);
   localLayoutParams.bottomMargin = (int)(0.5F + f1 * paramInt2);
   localLayoutParams.leftMargin = (int)(0.5F + f1 * paramInt3);
   localLayoutParams.rightMargin = localLayoutParams.leftMargin;
   this.as.setLayoutParams(localLayoutParams);
   this.as.requestLayout();
 }
Example #16
0
  /**
   * Moves a view to a screen position. Position is from 0 to 1 and converted to screen pixel.
   * Alignment is top left.
   *
   * @param view View to move
   * @param x X position from 0 to 1
   * @param y Y position from 0 to 1
   */
  public static void setLayoutPosition(Activity a, View view, double x, double y) {
    DisplayMetrics displayMetrics = a.getResources().getDisplayMetrics();
    float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density;
    float screenHeightDp = displayMetrics.heightPixels / displayMetrics.density;

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.leftMargin = Helper.getPixels(a, screenWidthDp * x);
    params.topMargin = Helper.getPixels(a, screenHeightDp * y);
    view.setLayoutParams(params);
  }
Example #17
0
  public int processJson(String json) {
    courseContainer.removeAllViews();
    int len = 0;
    try {
      L.d("解析所有课程", json);
      JSONArray jsonArray;
      jsonArray = new JSONArray(json);
      len = jsonArray.length();

      for (int i = 0; i < len; i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        Course course = new Course(jsonObject);

        // 将dp转换成px,因为设置RelativeLayout.LayoutParams 的margin只能传入px
        int _60dp = dpToPx(getActivity(), 60);
        int marginDp = dpToPx(getActivity(), 1.5f);

        int colWidth = courseContainer.getWidth() / 7;
        int xStartOffset = (Integer.valueOf(course.getLessonsBegin()) - 1) * (_60dp + marginDp);
        int xEndOffset = (Integer.valueOf(course.getLessonsEnd()) - 1) * (_60dp + marginDp);
        int yStartOffset = (Integer.valueOf(course.getDayOfWeek()) - 1) * colWidth;

        LinearLayout ll =
            (LinearLayout)
                LayoutInflater.from(getActivity()).inflate(R.layout.layout_onecourse, null);

        TextView courseName = (TextView) ll.findViewById(R.id.courseName);
        //				TextView detail = (TextView) ll.findViewById(R.id.detail);
        //				TextView teacher = (TextView) ll.findViewById(R.id.teacher);
        TextView room = (TextView) ll.findViewById(R.id.room);

        courseName.setText(course.getCourseName());
        // detail.setText(course.getDetail());
        // teacher.setText(course.getTeacher());
        room.setText(course.getRoom());

        RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(colWidth, xEndOffset - xStartOffset + _60dp);
        params.leftMargin = yStartOffset;
        params.topMargin = xStartOffset;

        courseContainer.addView(ll, params);

        ll.setOnClickListener(new CourseOnClickListener(course));
      }

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return len;
  }
  private void initOtherViews() {
    RelativeLayout.LayoutParams captureButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    captureButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    captureButtonParams.topMargin = screenHeight / 30;
    captureButton.setLayoutParams(captureButtonParams);
    captureText.setLayoutParams(captureButtonParams);
    captureText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    RelativeLayout.LayoutParams nameEditParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    nameEditParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    nameEditParams.addRule(RelativeLayout.BELOW, captureButton.getId());
    nameEditParams.topMargin = screenHeight / 30;
    nameEdit.setLayoutParams(nameEditParams);
    nameEdit.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    nameEdit.setTextColor(Color.BLACK);

    RelativeLayout.LayoutParams saveButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    saveButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    saveButtonParams.addRule(RelativeLayout.BELOW, nameEdit.getId());
    saveButtonParams.topMargin = screenHeight / 30;
    saveButton.setLayoutParams(saveButtonParams);
    saveButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    if (!isTraining) {
      deleteButtonFirstPos = screenHeight / 8 + screenHeight / 15;
      deleteButtonSecondPos = 3 * screenHeight / 8 + 2 * screenHeight / 15;
      RelativeLayout.LayoutParams deleteButtonParams =
          new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
      deleteButtonParams.topMargin = deleteButtonFirstPos;
      deleteButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      deleteButton.setLayoutParams(deleteButtonParams);
      deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    }
  }
  private void updateSelection() {
    if (mSelectedPlanet != null && mSelectionView != null) {
      mSelectionView.setVisibility(View.VISIBLE);

      RelativeLayout.LayoutParams params =
          (RelativeLayout.LayoutParams) mSelectionView.getLayoutParams();
      params.width =
          (int) ((((mSelectedPlanet.planet.getSize() - 10.0) / 8.0) + 4.0) * 10.0)
              + (int) (40 * getPixelScale());
      params.height = params.width;
      params.leftMargin = (int) (getLeft() + mSelectedPlanet.centre.x - (params.width / 2));
      params.topMargin = (int) (getTop() + mSelectedPlanet.centre.y - (params.height / 2));
      mSelectionView.setLayoutParams(params);
    }
  }
Example #20
0
 public void setupStatusBar() {
   RelativeLayout.LayoutParams layoutParams =
       (RelativeLayout.LayoutParams) headerText1.getLayoutParams();
   layoutParams.topMargin += getStatusBarHeight(getApplicationContext());
   headerText1.setLayoutParams(layoutParams);
   SystemBarTintManager tintManager = new SystemBarTintManager(this);
   // enable status bar tint
   tintManager.setStatusBarTintEnabled(true);
   // enable navigation bar tint
   tintManager.setNavigationBarTintEnabled(true);
   tintManager.setStatusBarAlpha(0.2f);
   tintManager.setNavigationBarAlpha(0.2f);
   tintManager.setTintAlpha(0.2f);
   tintManager.setTintColor(Color.parseColor("#0069FF"));
 }
 private void setRotateImageView() {
   RelativeLayout.LayoutParams params =
       (android.widget.RelativeLayout.LayoutParams) playerRoundIv.getLayoutParams();
   Bitmap bm =
       ((BitmapDrawable) (getResources().getDrawable(R.drawable.player_round))).getBitmap();
   params.width = bm.getWidth();
   params.height = bm.getHeight();
   if (BoxManagerUtils.getScreenDensity(context) > 1.5) {
     params.topMargin = 80;
   }
   playerRoundIv.setLayoutParams(params);
   playerRoundIv.roundCenter();
   playerRoundIv.setBitmap(bm);
   playerRoundIv.invalidate();
 }
Example #22
0
 public static void resetRL(View... view) {
   float rote = Handler_System.getWidthRoate(ApplicationBean.getApplication().getMode_w());
   if (view == null || rote == 1) {
     return;
   }
   for (View view2 : view) {
     RelativeLayout.LayoutParams layoutParams =
         (RelativeLayout.LayoutParams) view2.getLayoutParams();
     layoutParams.leftMargin = (int) (layoutParams.leftMargin * rote);
     layoutParams.rightMargin = (int) (layoutParams.rightMargin * rote);
     layoutParams.topMargin = (int) (layoutParams.topMargin * rote);
     layoutParams.bottomMargin = (int) (layoutParams.bottomMargin * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
  public void setProgressViewHidden(boolean hidden) {
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(mTextView.getLayoutParams());
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(
        RelativeLayout.LEFT_OF, hidden ? mLearningStatisticImageView.getId() : mImageView.getId());
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.leftMargin = (int) (10 * mScale);
    layoutParams.rightMargin = (int) (20 * mScale);
    layoutParams.bottomMargin = (int) (20 * mScale);
    layoutParams.topMargin = (int) (20 * mScale);
    mWrapper.setLayoutParams(layoutParams);

    mProgressBar.setVisibility(hidden ? View.GONE : View.VISIBLE);
  }
 private void showImagesOnScreen() {
   int coordY = getInitialY();
   for (int i = 0; i < 2; i++) {
     int coordX = getInitialX();
     for (int j = 0; j < 3; j++) {
       ImageView image = new ImageView(this);
       image.setImageResource(R.drawable.ball_white);
       RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(100, 100);
       lp.leftMargin = coordX;
       lp.topMargin = coordY;
       layout.addView(image, lp);
       coordX = coordX + 120;
     }
     coordY = coordY + 120;
   }
 }
Example #25
0
  /**
   * @Description: 添加视图到动画层
   *
   * @param @param vg
   * @param @param view
   * @param @param location
   * @param @return
   * @return View
   * @throws
   */
  public View addViewToAnimLayout(final View view, int[] location, int height, int width) {
    int x = location[0];
    int y = location[1];
    if (aniViewGroup == null) {
      aniViewGroup = createAnimLayout();
    }
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    lp.leftMargin = x;
    lp.topMargin = y;

    view.setLayoutParams(lp);
    aniViewGroup.addView(view);
    return view;
  }
  /**
   * ����������Ӧ��ͼƬ
   *
   * @param resId
   */
  private void setWeatherImage(int resId) {

    // �Ƴ�֮ǰ��ͼƬ
    if (layout != null) {
      layout.removeAllViews();
    }
    ImageView item = new ImageView(getParentFragment().getActivity());
    item.setImageResource(resId); // ����ͼƬ
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT); // �븸������������
    lp.topMargin = 10;
    item.setId(1); // �������View ��id
    item.setLayoutParams(lp); // ���ò��ֲ���
    layout.addView(item); // RelativeLayout�����View
  }
Example #27
0
  /*
   * 真正的实现方法
   */
  private void handleOpen(Message msg) {

    MLog.getIns().d("start");

    String[] params = msg.getData().getStringArray(EBaiduMapUtils.MAP_FUN_PARAMS_KEY);
    if (params == null || (params.length != 4 && params.length != 6)) {
      return;
    }

    int x = 0, y = 0, w = 0, h = 0;
    double lng = 0.0, lat = 0.0;
    boolean isUseLngLat = false;

    try {
      // 修复了前端调用open方法时传入小数时抛出NumberFormatException的问题 by waka 2016/01/23
      x = (int) Double.parseDouble(params[0]);
      y = (int) Double.parseDouble(params[1]);
      w = (int) Double.parseDouble(params[2]);
      h = (int) Double.parseDouble(params[3]);

      if (params.length == 6) {
        lng = Double.parseDouble(params[4]);
        lat = Double.parseDouble(params[5]);
        isUseLngLat = true;
      }
      if (mMapBaseFragment != null) {
        MLog.getIns().e("mMapBaseFragment != null");
        return;
      }
      mMapBaseFragment = new EBaiduMapBaseFragment();
      mMapBaseFragment.setBaseObj(this);
      if (isUseLngLat) {
        LatLng center = new LatLng(lat, lng);
        mMapBaseFragment.setStartCenter(center);
      }

      String activityId = EBaiduMapUtils.MAP_ACTIVITY_ID + EUExBaiduMap.this.hashCode();
      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(w, h);
      lp.leftMargin = x;
      lp.topMargin = y;
      addFragmentToCurrentWindow(mMapBaseFragment, lp, activityId);

    } catch (Exception e) {
      e.printStackTrace();
      MLog.getIns().e(e);
    }
  }
Example #28
0
  // the pin
  private ImageView getImagePin() {
    ivPin = new ImageView(getContext());
    int resId = getBitmapRes(activity, "pin");
    if (resId > 0) {
      ivPin.setImageResource(resId);
    }
    int dp_80 = dipToPx(getContext(), 80);
    int dp_36 = dipToPx(getContext(), 36);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(dp_80, dp_36);
    lp.topMargin = dipToPx(getContext(), 6);
    lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    ivPin.setLayoutParams(lp);
    ivPin.setVisibility(View.GONE);

    return ivPin;
  }
  protected void moveAlphaCursor() {
    final int measuredHeight = this.viewAlphaCheckered.getMeasuredHeight();
    float y = measuredHeight - ((this.getAlpha() * measuredHeight) / 255.f);
    final RelativeLayout.LayoutParams layoutParams =
        (RelativeLayout.LayoutParams) this.viewAlphaCursor.getLayoutParams();
    layoutParams.leftMargin =
        (int)
            (this.viewAlphaCheckered.getLeft()
                - Math.floor(this.viewAlphaCursor.getMeasuredWidth() / 2)
                - this.viewContainer.getPaddingLeft());
    layoutParams.topMargin =
        (int)
            ((this.viewAlphaCheckered.getTop() + y)
                - Math.floor(this.viewAlphaCursor.getMeasuredHeight() / 2)
                - this.viewContainer.getPaddingTop());

    this.viewAlphaCursor.setLayoutParams(layoutParams);
  }
 protected void moveCursor() {
   float y = viewHue.getMeasuredHeight() - (getHue() * viewHue.getMeasuredHeight() / 360.f);
   if (y == viewHue.getMeasuredHeight()) y = 0.f;
   RelativeLayout.LayoutParams layoutParams =
       (RelativeLayout.LayoutParams) viewCursor.getLayoutParams();
   layoutParams.leftMargin =
       (int)
           (viewHue.getLeft()
               - Math.floor(viewCursor.getMeasuredWidth() / 2)
               - viewContainer.getPaddingLeft());
   layoutParams.topMargin =
       (int)
           (viewHue.getTop()
               + y
               - Math.floor(viewCursor.getMeasuredHeight() / 2)
               - viewContainer.getPaddingTop());
   viewCursor.setLayoutParams(layoutParams);
 }