Пример #1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (vi == null) {
      vi = inflater.inflate(R.layout.row_chat_box, null);
    }
    try {
      JSONObject json_data = new JSONObject(data.get(position));
      LinearLayout right_delete_box = (LinearLayout) vi.findViewById(R.id.right_delete_box);
      LinearLayout left_delete_box = (LinearLayout) vi.findViewById(R.id.left_delete_box);
      LinearLayout row_box = (LinearLayout) vi.findViewById(R.id.row_box);
      LinearLayout chat_box = (LinearLayout) vi.findViewById(R.id.chat_box);
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_box.getLayoutParams();
      int left = Math.round(100 * this.context.getResources().getDisplayMetrics().density);
      int top = Math.round(5 * this.context.getResources().getDisplayMetrics().density);
      int right = Math.round(10 * this.context.getResources().getDisplayMetrics().density);
      if (json_data.getString("sender_id").equals(jsonuser.getString(TblUsers.USER_ID))) {
        params.setMargins(left, top, right, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        row_box.setBackgroundResource(R.drawable.bg_chat_box);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.VISIBLE);
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.VISIBLE);

        if (json_data.getString("read").equals("0")) {
          chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        }
      } else {
        params.setMargins(right, top, left, top);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
        row_box.setBackgroundResource(R.drawable.bg_button_deactive);
        chat_box.findViewById(R.id.img_mark).setVisibility(View.GONE);
        right_delete_box.setVisibility(View.VISIBLE);
        left_delete_box.setVisibility(View.GONE);
      }

      if (ChatBoxActivity.allow_edit == 0) {
        right_delete_box.setVisibility(View.GONE);
        left_delete_box.setVisibility(View.GONE);
      }
      chat_box.setLayoutParams(params);

      right_delete_box.setClickable(true);
      right_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      left_delete_box.setClickable(true);
      left_delete_box.setOnClickListener(deleteMessage(position, data.get(position)));

      ((TextView) vi.findViewById(R.id.chat_text)).setText(json_data.getString("conversation"));
      ((TextView) vi.findViewById(R.id.chat_text)).setAutoLinkMask(1);

      String timing_send =
          FormatDateTime.formatAutoGetDateTimeForMessage(json_data.getString("timing_send"));
      ((TextView) vi.findViewById(R.id.message_time)).setText(timing_send);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return vi;
  }
Пример #2
0
  @Override
  public void onResume() {
    super.onResume();
    if (super.getUser().isQuickInsertActivity()) {
      RelativeLayout activityList = (RelativeLayout) findViewById(R.id.activitylist);

      RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(0, 0, 0, 50);

      activityList.setLayoutParams(layoutParams);

      RelativeLayout quickActivityInsert = (RelativeLayout) findViewById(R.id.quickinsertactivity);
      quickActivityInsert.setVisibility(View.VISIBLE);

    } else {
      RelativeLayout activityList = (RelativeLayout) findViewById(R.id.activitylist);

      RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(0, 0, 0, 0);

      activityList.setLayoutParams(layoutParams);

      RelativeLayout quickActivityInsert = (RelativeLayout) findViewById(R.id.quickinsertactivity);
      quickActivityInsert.setVisibility(View.GONE);
    }
  }
Пример #3
0
 private void selectCard(View card) {
   RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) card.getLayoutParams();
   if (params.bottomMargin > minBottomMargin)
     params.setMargins(params.leftMargin, 0, 0, params.bottomMargin - 20);
   else params.setMargins(params.leftMargin, 0, 0, params.bottomMargin + 20);
   card.setLayoutParams(params);
 }
Пример #4
0
  private void initItems() {
    // 避免冲突
    if (getChildCount() > 0) {
      return;
    }

    int screenWidth = wm.getDefaultDisplay().getWidth();
    int initCols =
        screenWidth % rowWidth == 0 ? screenWidth / rowWidth : screenWidth / rowWidth + 1;

    int initLength = Math.min(adapter.getCount(), initCols * 2 * rows);
    for (int i = 0; i < initLength; i++) {
      int left = (i / rows) * (itemWidth + spaceHori);
      int top = (i % rows) * (spaceVert + itemHeight);
      RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(itemWidth, itemHeight);
      if (initLength == 1) {
        rlp.setMargins(left, top, 0, paddingTop * 2);
      } else {
        rlp.setMargins(left, top, 0, 0);
      }

      View child = adapter.getView(i, null, this);
      this.addView(child, rlp);
      int viewId = child.getId();
      if (viewId == -1) {
        viewId = TvUtil.buildId();
        // 此处硬设置id同时建议开发者不用此范围id
      }
      child.setId(viewId);
      itemIds.put(viewId, i);
      bindEventOnChild(child, i);
      layoutFlag = true;
    }
    colCount = itemIds.size() % rows == 0 ? itemIds.size() / rows : itemIds.size() / rows + 1;

    cursor = new ImageView(getContext());
    cursorId = TvUtil.buildId();
    cursor.setId(cursorId);
    cursor.setBackgroundResource(cursorRes);
    this.addView(cursor);
    cursor.setVisibility(View.INVISIBLE);

    if (initFocus) {
      View focus = ((ViewGroup) getParent()).findFocus();
      if (focus == null) {
        View item = getChildAt(0);
        if (item != null) {
          item.requestFocus();
        }
      }
    }
  }
  @Override
  public void getActionsLayout(Context ctx, final LinearLayout cont) {
    WindowManager mWinMgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    int displayWidth = mWinMgr.getDefaultDisplay().getWidth();
    cont.removeAllViews();
    final TextView cmd = new TextView(ctx);

    cmd.setText(Html.fromHtml("<b>Reading:</b> " + getOutputCelsius() + "°C"));
    if (prefs.isLightThemeSelected()) cmd.setTextColor(ctx.getResources().getColor(R.color.black));
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    cmd.setLayoutParams(lp);
    lp.setMargins(2, 0, 0, 2);
    // cmd.setGravity(Gravity.TOP);
    cont.addView(cmd);

    ProgressBar par = new ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal);
    // ProgressBar sfumata
    final ShapeDrawable pgDrawable =
        new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
    final LinearGradient gradient =
        new LinearGradient(
            0,
            0,
            displayWidth / 2,
            0,
            ctx.getResources().getColor(color.aa_blue),
            ctx.getResources().getColor(color.aa_red),
            android.graphics.Shader.TileMode.CLAMP);
    pgDrawable.getPaint().setStrokeWidth(3);
    pgDrawable.getPaint().setDither(true);
    pgDrawable.getPaint().setShader(gradient);

    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    par.setProgressDrawable(progress);
    par.setBackgroundResource(android.R.drawable.progress_horizontal);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    lp2.setMargins(2, 2, 4, 2);
    par.setLayoutParams(lp2);
    par.setMax(50);
    par.setProgress(20);
    par.setProgress(0);
    par.setMax(40);
    par.setProgress((int) getOutputFloat());

    cont.addView(par);
  }
Пример #6
0
  private void setMarginsOnBtns(int midScreen) {
    Button btn = (Button) this.findViewById(R.id.playBtn);
    RelativeLayout.LayoutParams playParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    playParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    playParams.setMargins(midScreen + 100, 0, 0, 0);
    btn.setLayoutParams(playParams);

    Button btn2 = (Button) this.findViewById(R.id.passBtn);
    RelativeLayout.LayoutParams passParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    passParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    passParams.setMargins(midScreen - 100 - btn2.getWidth(), 0, 0, 0);
    btn2.setLayoutParams(passParams);
  }
Пример #7
0
  public RowCheckBoxOmegaFi(Context context) {
    super(context);
    setTextSizeInformation(
        context.getResources().getDimensionPixelSize(R.dimen.text_12_notification));
    checkOption = new CheckBox(context);
    checkOption.setEnabled(true);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(params.leftMargin, params.topMargin, 10, params.bottomMargin);
    checkOption.setLayoutParams(params);
    checkOption.setButtonDrawable(R.drawable.radio_button);
    checkOption.setSoundEffectsEnabled(true);
    this.addViewRight(checkOption);
    setTextColor(Color.GRAY);
    setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.d("onclick listener row", checkOption.isChecked() + "");
            checkOption.setChecked(!checkOption.isChecked());
          }
        });
  }
Пример #8
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_contar_caracteres, container, false);

    /*----------Poner  posicion al fragment layout (mi layout es un Relativelayout)------*/
    // Nuevos parametros para el view del fragmento
    RelativeLayout.LayoutParams parametro =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    // Nueva Regla: EL fragmento estara debajo del boton add_fragment
    parametro.addRule(RelativeLayout.BELOW, R.id.add_fragmento);
    // Margenes: top:41dp
    parametro.setMargins(0, 41, 0, 0);
    // Setear los parametros al view
    view.setLayoutParams(parametro);
    /*-----------------------------------------------------------------------------------*/

    btnBoton = (Button) view.findViewById(R.id.main_button);
    lbltexto = (TextView) view.findViewById(R.id.main_textview);
    txtEdit = (EditText) view.findViewById(R.id.main_editText);

    btnBoton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            lbltexto.setText(String.valueOf(txtEdit.getText().length()));
          }
        });

    return view;
  }
Пример #9
0
  // shared image container
  private RelativeLayout getThumbView() {
    rlThumb = new RelativeLayout(getContext());
    rlThumb.setId(1);
    int dp_82 = dipToPx(getContext(), 82);
    int dp_98 = dipToPx(getContext(), 98);
    LayoutParams lpThumb = new LayoutParams(dp_82, dp_98);
    rlThumb.setLayoutParams(lpThumb);

    ivImage = new ImageView(getContext());
    int resId = getBitmapRes(activity, "btn_back_nor");
    if (resId > 0) {
      ivImage.setBackgroundResource(resId);
    }
    ivImage.setScaleType(ScaleType.CENTER_INSIDE);
    ivImage.setImageBitmap(image);

    int dp_4 = dipToPx(getContext(), 4);
    ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
    int dp_74 = dipToPx(getContext(), 74);
    RelativeLayout.LayoutParams lpImage = new RelativeLayout.LayoutParams(dp_74, dp_74);
    int dp_16 = dipToPx(getContext(), 16);
    int dp_8 = dipToPx(getContext(), 8);
    lpImage.setMargins(0, dp_16, dp_8, 0);
    ivImage.setLayoutParams(lpImage);
    ivImage.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (image != null && !image.isRecycled()) {
              PicViewer pv = new PicViewer();
              pv.setImageBitmap(image);
              pv.show(activity, null);
            }
          }
        });
    rlThumb.addView(ivImage);

    Button btn = new Button(getContext());
    btn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // remove the photo to share
            rlThumb.setVisibility(View.GONE);
            ivPin.setVisibility(View.GONE);
            removeImage(imgInfo);
          }
        });
    resId = getBitmapRes(activity, "img_cancel");
    if (resId > 0) {
      btn.setBackgroundResource(resId);
    }
    int dp_20 = dipToPx(getContext(), 20);
    RelativeLayout.LayoutParams lpBtn = new RelativeLayout.LayoutParams(dp_20, dp_20);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    btn.setLayoutParams(lpBtn);
    rlThumb.addView(btn);

    rlThumb.setVisibility(View.GONE);
    return rlThumb;
  }
Пример #10
0
  // page body
  private LinearLayout getPageBody() {
    llBody = new LinearLayout(getContext());
    llBody.setId(2);
    int resId = getBitmapRes(activity, "edittext_back");
    if (resId > 0) {
      llBody.setBackgroundResource(resId);
    }
    llBody.setOrientation(LinearLayout.VERTICAL);
    RelativeLayout.LayoutParams lpBody =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId());
    lpBody.addRule(RelativeLayout.BELOW, llTitle.getId());
    lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId());
    if (!dialogMode) {
      lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    int dp_3 = dipToPx(getContext(), 3);
    lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
    llBody.setLayoutParams(lpBody);

    llBody.addView(getMainBody());
    llBody.addView(getSep());
    llBody.addView(getPlatformList());

    return llBody;
  }
Пример #11
0
  protected void setRightButtonText(String text) {
    RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view);
    rightView.removeAllViews();

    int padding = dp2px(6);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.setMargins(0, 0, dp2px(8), 0);
    TextView tv = new TextView(this);
    tv.setText(text);
    tv.setTextColor(0xFF666666);
    tv.setTextSize(16.f);
    tv.setLayoutParams(lp);
    tv.setBackgroundResource(R.drawable.btn_gray);
    tv.setPadding(2 * padding, padding, 2 * padding, padding);
    tv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onRightButtonClicked(v);
          }
        });

    rightView.addView(tv);
    rightView.setVisibility(View.VISIBLE);
  }
Пример #12
0
  public void resetTouchFocus() {
    if (!mInitialized) return;

    splitMode = false;
    mMeteringIndicatorRotateLayout.setVisibility(View.GONE);

    // Put focus indicator to the center.
    RelativeLayout.LayoutParams p =
        (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.getLayoutParams();
    int[] rules = p.getRules();
    rules[RelativeLayout.CENTER_IN_PARENT] = RelativeLayout.TRUE;
    p.setMargins(0, 0, 0, 0);

    mFocusArea = null;
    mMeteringArea = null;

    // allow driver to choose whatever it wants for focusing / metering
    // without these two lines Continuous focus is not re-enabled on HTC One
    int focusMode = getFocusMode();
    if ((focusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
            || focusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO
            || focusMode == CameraParameters.AF_MODE_AUTO
            || focusMode == CameraParameters.AF_MODE_MACRO)
        && mFocusAreaSupported) {
      String modeName =
          PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext())
              .getString("defaultModeName", null);
      boolean isVideoRecording =
          PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext())
              .getBoolean("videorecording", false);
    }
  }
Пример #13
0
  protected void initView() {
    setContentViewSrc(R.layout.activity_web_layout);
    webView = new WebActivityFragment();
    pb_bar = (ProgressBar) findViewById(R.id.pb_bar);
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.fl_content, webView);
    ft.commit();

    refresh = new ImageView(this);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(CommonUtils.dp2px(30), CommonUtils.dp2px(30));
    params.setMargins(0, 0, CommonUtils.dp2px(10), 0);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    refresh.setLayoutParams(params);
    if (!isUseToolbar()) addOptionsMenu(refresh);
    refresh.setBackgroundResource(R.mipmap.ic_refresh);
    refresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isLoading) webView.stopLoading();
            else webView.refresh();
          }
        });
  }
Пример #14
0
  private void addNewItems() {

    currentChildCount = getChildCount();
    parentLayout = false;
    int start = itemIds.size();
    int end = Math.min(start + screenMaxColumns * rows * 2, adapter.getCount());

    for (int i = start; i < end; i++) {
      int left = (i / rows) * (itemWidth + spaceHori);
      int top = (i % rows) * (spaceVert + itemHeight);
      RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(itemWidth, itemHeight);
      rlp.setMargins(left, top, 0, 0);
      View child = adapter.getView(i, null, this);
      this.addView(child, rlp);
      int viewId = child.getId();
      if (viewId == -1) {
        viewId = TvUtil.buildId();
        // 此处硬设置id同时建议开发者不用此范围id
      }
      child.setId(viewId);
      itemIds.put(viewId, i);
      bindEventOnChild(child, i);
      layoutFlag = true;
    }

    colCount = itemIds.size() % rows == 0 ? itemIds.size() / rows : itemIds.size() / rows + 1;
  }
Пример #15
0
  public void add_car(int x, int y, int rotation, int state) {

    ImageView car = new ImageView(getActivity());

    carList.add(car);
    switch (state) {
      case 0:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher0));
        break;
      case 1:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher1));
        break;
      case 2:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher2));
        break;
      default:
        break;
    }

    RelativeLayout.LayoutParams layoutParams =
        new LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(x, y, 10, 10); // 150-1650/50-950
    car.setRotation(rotation);
    layout.addView(car, layoutParams);
  }
Пример #16
0
  private void init() {
    setHardwareAccelerated(true);

    boolean hasShot =
        getContext()
            .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE)
            .getBoolean("hasShot" + getConfigOptions().showcaseId, false);
    if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) {
      // The showcase has already been shot once, so we don't need to do anything
      setVisibility(View.GONE);
      mIsRedundant = true;
      return;
    }

    mShowcaseRadius = mMetricScale * INNER_CIRCLE_RADIUS;
    setOnTouchListener(this);

    if (!mOptions.noButton && mEndButton.getParent() == null) {
      RelativeLayout.LayoutParams lps = getConfigOptions().buttonLayoutParams;
      if (lps == null) {
        lps = (LayoutParams) generateDefaultLayoutParams();
        lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        int margin = ((Number) (mMetricScale * 12)).intValue();
        lps.setMargins(margin, margin, margin, margin);
      }
      mEndButton.setLayoutParams(lps);
      mEndButton.setText(mButtonText != null ? mButtonText : getResources().getString(R.string.ok));
      if (!mHasCustomClickListener) {
        mEndButton.setOnClickListener(this);
      }
      addView(mEndButton);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("WOW");

    view = new CustomView(getApplicationContext(), actionBar);
    setContentView(view);
    view.setRefreshListner(SampleForGmailLikePullToRefresh.this);
    view.setActionBar(SampleForGmailLikePullToRefresh.this);
    mListView = view.getListView();

    list = new ArrayList<Integer>();
    adapter = new DummyAdapter(SampleForGmailLikePullToRefresh.this, 0, list);

    LayoutInflater layoutInflater =
        (LayoutInflater)
            SampleForGmailLikePullToRefresh.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View loadingView = layoutInflater.inflate(R.layout.view_listview_loading, null);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    params.setMargins(0, 5, 0, 0);
    loadingView.setLayoutParams(params);
    mListView.setEmptyView(null);
  }
Пример #18
0
 /** 距离屏幕左右的边距 */
 public EasyDialog setMarginLeftAndRight(int left, int right) {
   RelativeLayout.LayoutParams layoutParams =
       (RelativeLayout.LayoutParams) llContent.getLayoutParams();
   layoutParams.setMargins(left, 0, right, 0);
   llContent.setLayoutParams(layoutParams);
   return this;
 }
Пример #19
0
 private void setImage(Bitmap bitmap) {
   bgView.setImageBitmap(bitmap);
   RelativeLayout.LayoutParams layoutParams =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
   layoutParams.setMargins(0, 0, 0, 0);
   bgView.setLayoutParams(layoutParams);
 }
Пример #20
0
 private void changeImagePos(AdInfo adinfo) {
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   lp.height = mContext.getResources().getInteger(R.integer.ad_target_image_height);
   lp.width = mContext.getResources().getInteger(R.integer.ad_target_image_width);
   switch (mContext.getResources().getConfiguration().densityDpi) {
     case Constants.DENSITY_1280:
       lp.setMargins(adinfo.getPos_x(), adinfo.getPos_y(), 0, 0);
       break;
     case Constants.DENSITY_1920:
       lp.setMargins((int) (adinfo.getPos_x() * 1.5), (int) (adinfo.getPos_y() * 1.5), 0, 0);
       break;
     default:
   }
   mAdView.setLayoutParams(lp);
 }
Пример #21
0
  public ImageAdapter(Context context, int type) {
    super(context, type);

    if (type == 1)
      layout_param = new RelativeLayout.LayoutParams(this.getWidth() / 2, this.getWidth() / 2);
    else layout_param = new RelativeLayout.LayoutParams(this.getWidth() / 3, this.getWidth() / 3);

    layout_param.setMargins(1, 0, 0, 1);
  }
Пример #22
0
    void show(boolean alignTop) {
      RelativeLayout.LayoutParams lp =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

      if (alignTop) {
        lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        lp.setMargins(0, 20, 0, 0);
      } else {
        lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        lp.setMargins(0, 0, 0, 60);
      }

      hide();

      ((ViewGroup) map.getParent()).addView(popup, lp);
      isVisible = true;
    }
Пример #23
0
 /**
  * Define the layout that will act as the container to hold the video. This will be passed in,
  * along with the context and the SMIL message during translation.
  */
 private RelativeLayout loadVideoContainer() {
   RelativeLayout videoContainer = new RelativeLayout(this);
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
   lp.setMargins(0, 0, 0, 0);
   videoContainer.setLayoutParams(lp);
   this.rootView.addView(videoContainer);
   return videoContainer;
 }
 public RelativeLayout.LayoutParams getLayoutParams(RelativeLayout layout) {
   RelativeLayout.LayoutParams params =
       new RelativeLayout.LayoutParams(
           width != null ? width : WRAP, height != null ? height : WRAP);
   params.setMargins(marginLeft, marginTop, marginRight, marginBottom);
   for (RelativeLayoutRule rule : relativeLayoutRules) {
     params.addRule(rule.verb, rule.anchor);
   }
   return params;
 }
Пример #25
0
  private void init() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      setLayerType(LAYER_TYPE_SOFTWARE, null);
    } else {
      setDrawingCacheEnabled(true);
    }

    boolean hasShot =
        getContext()
            .getSharedPreferences(PREFS_SHOWCASE_INTERNAL, Context.MODE_PRIVATE)
            .getBoolean("hasShot" + getConfigOptions().showcaseId, false);
    if (hasShot && mOptions.shotType == TYPE_ONE_SHOT) {
      // The showcase has already been shot once, so we don't need to do anything
      setVisibility(View.GONE);
      isRedundant = true;
      return;
    }
    showcase = getContext().getResources().getDrawable(R.drawable.cling);

    showcaseRadius = metricScale * INNER_CIRCLE_RADIUS;
    PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY);
    setOnTouchListener(this);

    mPaintTitle = new Paint();
    mPaintTitle.setColor(titleTextColor);
    mPaintTitle.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY);
    mPaintTitle.setTextSize(24 * metricScale);
    mPaintTitle.setAntiAlias(true);

    mPaintDetail = new TextPaint();
    mPaintDetail.setColor(detailTextColor);
    mPaintDetail.setShadowLayer(2.0f, 0f, 2.0f, Color.DKGRAY);
    mPaintDetail.setTextSize(16 * metricScale);
    mPaintDetail.setAntiAlias(true);

    mEraser = new Paint();
    mEraser.setColor(0xFFFFFF);
    mEraser.setAlpha(0);
    mEraser.setXfermode(mBlender);
    mEraser.setAntiAlias(true);

    if (!mOptions.noButton && mEndButton.getParent() == null) {
      RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams();
      lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      int margin = ((Number) (metricScale * 12)).intValue();
      lps.setMargins(margin, margin, margin, margin);
      lps.height = LayoutParams.WRAP_CONTENT;
      lps.width = LayoutParams.WRAP_CONTENT;
      mEndButton.setLayoutParams(lps);
      mEndButton.setText(buttonText != null ? buttonText : getResources().getString(R.string.ok));
      if (!hasCustomClickListener) mEndButton.setOnClickListener(this);
      addView(mEndButton);
    }
  }
  public void InitializePosition() {
    _zeroPoint = ((ImageView) FlowIconSingleton._fullLayout.findViewById(R.id.homeIcon)).getLeft();
    _goalPoint = FlowIconSingleton._closeIcon.getLeft();

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(_zeroPoint, UsualMethod.ChangeDpiIntoPixel(10), 0, 0);
    FlowIconSingleton._closeIcon.setLayoutParams(params);
    FlowIconSingleton._windowManager.updateViewLayout(
        FlowIconSingleton._fullLayout, FlowIconSingleton._fullPageParams);
  }
 private void resetView() {
   Log.i(TAG, "resetView mUnCropWidth = " + mUnCropWidth + " mUnCropHeight = " + mUnCropHeight);
   RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
   setBackground(null);
   animate().cancel();
   setScaleX(1f);
   setScaleY(1f);
   params.width = mUnCropWidth;
   params.height = mUnCropHeight;
   params.setMargins(0, 0, 0, 0);
 }
 public void alignUnderView(View v) {
   if (rlpUnderView == null) {
     rlpUnderView =
         new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.FILL_PARENT,
             (int) (Metrics.squareButtonSize * Metrics.squareButtonScale));
     rlpUnderView.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
     rlpUnderView.setMargins(Metrics.screenMargin, Metrics.screenMargin, Metrics.screenMargin, 0);
   }
   rlpUnderView.addRule(RelativeLayout.BELOW, v.getId());
   layout.setLayoutParams(rlpUnderView);
 }
Пример #29
0
  private void init(AttributeSet attrs) {
    String text = null;
    if (attrs != null) {
      TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RltItem, 0, 0);
      text = a.getString(R.styleable.RltItem_text);
    }
    this.setBackgroundResource(R.drawable.title_right_bg_selector);
    this.setGravity(Gravity.CENTER_VERTICAL);
    this.setClickable(true);

    TextView tv = new TextView(getContext());
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.setMargins(
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10));
    tv.setLayoutParams(lp);
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(getResources().getColor(R.color.c_white_ffffff));
    tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    tv.setText(text);
    this.addView(tv);
    ImageView iv = new ImageView(getContext());
    RelativeLayout.LayoutParams rlp =
        new LayoutParams(DisplayUtil.dip2px(20), DisplayUtil.dip2px(40));
    rlp.setMargins(
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10),
        DisplayUtil.dip2px(10));
    rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    iv.setLayoutParams(rlp);
    iv.setPadding(
        DisplayUtil.dip2px(5), DisplayUtil.dip2px(5), DisplayUtil.dip2px(5), DisplayUtil.dip2px(5));
    iv.setImageResource(R.mipmap.icon_arrow);
    this.addView(iv);
  }
Пример #30
0
  private void alignSeekThumb() {
    scrubberThumb.setTime(seekBar.getProgress());
    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) scrubberThumb.getLayoutParams();

    double progress = seekBar.getProgress() / (double) seekBar.getMax();
    int leftOffset = (int) (seekBar.getWidth() * progress) - scrubberThumb.getWidth() / 2;
    leftOffset = Math.min(leftOffset, seekBar.getWidth() - scrubberThumb.getWidth());
    leftOffset = Math.max(leftOffset, 0);

    params.setMargins(leftOffset, params.topMargin, params.rightMargin, params.bottomMargin);
    scrubberThumb.setLayoutParams(params);
  }