Beispiel #1
0
  // Initializes the origin state of the layer
  private void initState() {

    // Sticks container to right or left
    RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) mSlidingLayer.getLayoutParams();
    int textResource;
    Drawable d;

    if (mStickContainerToRightLeftOrMiddle.equals("right")) {
      textResource = R.string.app_name;
      d = getResources().getDrawable(R.drawable.ic_launcher);

      rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else if (mStickContainerToRightLeftOrMiddle.equals("left")) {
      textResource = R.string.swipe_left_label;
      d = getResources().getDrawable(R.drawable.container_rocket_left);

      rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    } else if (mStickContainerToRightLeftOrMiddle.equals("top")) {
      textResource = R.string.swipe_up_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_TOP);
      rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
      rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);
    } else if (mStickContainerToRightLeftOrMiddle.equals("bottom")) {
      textResource = R.string.swipe_down_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_BOTTOM);
      rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
      rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);
    } else {
      textResource = R.string.swipe_label;
      d = getResources().getDrawable(R.drawable.container_rocket);

      rlp.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
    }

    d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    swipeText.setCompoundDrawables(null, d, null, null);
    swipeText.setText(getResources().getString(textResource));
    mSlidingLayer.setLayoutParams(rlp);

    // Sets the shadow of the container
    if (mShowShadow) {
      mSlidingLayer.setShadowWidthRes(R.dimen.shadow_width);
      mSlidingLayer.setShadowDrawable(R.drawable.sidebar_shadow);
    } else {
      mSlidingLayer.setShadowWidth(0);
      mSlidingLayer.setShadowDrawable(null);
    }
    if (mShowOffset) {
      mSlidingLayer.setOffsetWidth(getResources().getDimensionPixelOffset(R.dimen.offset_width));
    } else {
      mSlidingLayer.setOffsetWidth(0);
    }
  }
 private void resizeImageAndInfoView() {
   RelativeLayout.LayoutParams rllp = (RelativeLayout.LayoutParams) ivImage.getLayoutParams();
   int screenWidth = mApplication.getnScreenWidth();
   screenWidth = screenWidth - dip2px(UploadLicenceActivity.this, 32);
   rllp.width = screenWidth;
   rllp.height = screenWidth * 30 / 43;
   ivImage.setLayoutParams(rllp);
   RelativeLayout.LayoutParams lllp = (RelativeLayout.LayoutParams) userInfoView.getLayoutParams();
   lllp.width = screenWidth;
   lllp.height = screenWidth * 30 / 43;
   userInfoView.setLayoutParams(lllp);
 }
  public TopButtonController(RelativeLayout rootLayour, GameActivity activity) {
    this.activity = activity;
    prefs = UserPreferences.getInstance(activity);

    layout =
        (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.partial_topbuttons, null);
    pauseBtn = (ImageView) layout.findViewById(R.id.pauseBtn);
    hintBtn = (OutlinedTextView) layout.findViewById(R.id.hintBtn);
    nextBtn = (ImageView) layout.findViewById(R.id.nextBtn);
    restartBtn = (ImageView) layout.findViewById(R.id.restartBtn);
    menuBtn = (ImageView) layout.findViewById(R.id.menuBtn);
    helpBtn = (ImageView) layout.findViewById(R.id.helpBtn);

    pauseBtn.setOnClickListener(mainListener);
    hintBtn.setOnClickListener(mainListener);
    nextBtn.setOnClickListener(mainListener);
    restartBtn.setOnClickListener(mainListener);
    menuBtn.setOnClickListener(mainListener);
    helpBtn.setOnClickListener(mainListener);

    rlpTop =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            Math.round(Metrics.squareButtonSize * Metrics.squareButtonScale));
    rlpTop.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    rlpTop.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rlpTop.setMargins(Metrics.screenMargin, Metrics.screenMargin, Metrics.screenMargin, 0);

    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) hintBtn.getLayoutParams();
    int bgWidth = hintBtn.getBackground().getIntrinsicWidth();
    int bgHeight = hintBtn.getBackground().getIntrinsicHeight();
    float scale = ((float) rlpTop.height / bgHeight);
    lp.width = Math.round(bgWidth * scale);
    lp.height = rlpTop.height;
    int[] iPaddings = {27, 23, 94, 23};
    hintBtn.setPadding(
        (int) (iPaddings[0] * scale),
        (int) (iPaddings[1] * scale),
        (int) (iPaddings[2] * scale),
        (int) (iPaddings[3] * scale));
    hintBtn.setLayoutParams(lp);
    hintBtn.setTypeface(Resources.getFont(activity.getApplicationContext()));
    hintBtn.setMaxLines2(1);
    updateHints();

    addScoreCounter();
    rootLayour.addView(layout, rlpTop);

    lp = (RelativeLayout.LayoutParams) pauseBtn.getLayoutParams();
    lp.width = lp.height = rlpTop.height;
  }
Beispiel #4
0
 public static void imageRLViewReset(ImageView imageView, int bitmapW, int bitmapH) {
   RelativeLayout.LayoutParams layoutParams =
       (RelativeLayout.LayoutParams) imageView.getLayoutParams();
   HashMap<String, Integer> data = Handler_System.getDisplayMetrics();
   int width = data.get(Handler_System.systemWidth);
   int height = data.get(Handler_System.systemHeight);
   if (width > height) {
     layoutParams.width = (int) (bitmapW * 1.00f / bitmapH * height);
     layoutParams.height = height;
   } else {
     layoutParams.width = width;
     layoutParams.height = (int) (bitmapH * 1.00f / bitmapW * width);
   }
   imageView.setLayoutParams(layoutParams);
 }
 @SuppressLint("ResourceAsColor")
 @Override
 public View getView(int arg0, View arg1, ViewGroup arg2) {
   HolerView holerView = null;
   if (arg1 == null) {
     holerView = new HolerView();
     arg1 =
         LayoutInflater.from(ChoiceCollActivity.this)
             .inflate(R.layout.commodity_item, arg2, false);
     holerView.table = (TextView) arg1.findViewById(R.id.table);
     arg1.setTag(holerView);
   } else {
     holerView = (HolerView) arg1.getTag();
   }
   RelativeLayout.LayoutParams param =
       (RelativeLayout.LayoutParams) holerView.table.getLayoutParams();
   param.height = mCommodityListView.getHeight() / 10;
   holerView.table.setLayoutParams(param);
   holerView.table.setText(mCommodityListData.get(arg0));
   if (mCommodityListFlg.get(arg0)) {
     holerView.table.setBackgroundResource(R.color.white);
   } else {
     holerView.table.setBackgroundResource(R.color.item_of);
   }
   return arg1;
 }
Beispiel #6
0
  public UserDetail(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.linearlayout_userdetail, this);
    imageviewbili = (ImageView) findViewById(R.id.littletv);
    imageviewbili.setOnTouchListener(this);
    imageviewbili.setBackgroundResource(R.drawable.bili_up);
    ImageView usericon = (ImageView) findViewById(R.id.usericon);
    TextView textview = (TextView) findViewById(R.id.username);

    RelativeLayout.LayoutParams layoutParamsb =
        (RelativeLayout.LayoutParams) imageviewbili.getLayoutParams();
    layoutParamsb.height = (int) (MainActivity.window_height * 3 / 11 / 1.5);
    layoutParamsb.width = 270 * layoutParamsb.height / 208;
    imageviewbili.setLayoutParams(layoutParamsb);

    StyleController.contextinStyleController = context;
    setusernametextTheme(textview);
    data = getData();
    UserDetailAdapter adapter = new UserDetailAdapter(context);
    lv = (ListView) findViewById(R.id.userlv);
    lv.setAdapter(adapter);
    lv.setDividerHeight(1);
  }
  private void addSearchLayout(RelativeLayout layout, TiViewProxy searchView, TiUIView search) {
    RelativeLayout.LayoutParams p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    TiDimension rawHeight;
    if (searchView.hasProperty(TiC.PROPERTY_HEIGHT)) {
      rawHeight = TiConvert.toTiDimension(searchView.getProperty(TiC.PROPERTY_HEIGHT), 0);
    } else {
      rawHeight = TiConvert.toTiDimension(MIN_SEARCH_HEIGHT, 0);
    }
    p.height = rawHeight.getAsPixels(layout);

    View nativeView = search.getNativeView();
    layout.addView(nativeView, p);

    p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    p.addRule(RelativeLayout.BELOW, nativeView.getId());
    ViewParent parentWrapper = wrapper.getParent();
    if (parentWrapper != null && parentWrapper instanceof ViewGroup) {
      // get the previous layout params so we can reset with new layout
      ViewGroup.LayoutParams lp = wrapper.getLayoutParams();
      ViewGroup parentView = (ViewGroup) parentWrapper;
      // remove view from parent
      parentView.removeView(wrapper);
      // add new layout
      layout.addView(wrapper, p);
      parentView.addView(layout, lp);

    } else {
      layout.addView(wrapper, p);
    }
    this.searchLayout = layout;
  }
  public void initView(EUExIconList mEUExIconList) {
    this.mEUExIconList = mEUExIconList;
    /** 大约计算gridItem的高度 */
    float gridViewHight = UIConfig.getScaleHight() / UIConfig.getLine();
    int viewGroupBottomPadding =
        (int) (UIConfig.getGridScaleHight() * UIConfig.VIEWGROUP_BOTTOM_PADDING_HIGHT_SCALE);
    UIConfig.setPageIndicatorScaleHight(
        (int) (gridViewHight * UIConfig.PAGE_INDICATOR_HIGHT_SCALE));
    /** 精确计算gridItem的高度 gridItem的高度=(总高度-页码指示器高度 - viewGroupTopPadding - topPadding)/ 行数 */
    gridViewHight =
        (UIConfig.getScaleHight() - UIConfig.getPageIndicatorScaleHight() - viewGroupBottomPadding)
            / UIConfig.getLine();
    UIConfig.setGridScaleHight(gridViewHight);
    UIConfig.setTitleScaleHight((int) (gridViewHight * UIConfig.TITLE_HIGHT_SCALE));
    /** icon 高度 = gridItemHight * ICON_HIGHT_SCALE - iconTopPadding - iconBottomPadding */
    UIConfig.setIconScaleHight(
        (int)
            (gridViewHight * UIConfig.ICON_HIGHT_SCALE
                - UIConfig.getGridScaleHight() * UIConfig.ICON_PADDING_HIGHT_SCALE));
    UIConfig.setIconScaleWidth(UIConfig.getScaleWidth() / UIConfig.getRow());
    if (UIConfig.isShowIconFrame()) {
      UIConfig.setIconFrameWidth(
          UIConfig.getIconScaleHight() * UIConfig.ICON_FRAME_VISIBLE_WIDTH_SCALE);
    }
    mContainer.initFramePaint();
    // 动态设置Container每页的列数为2行
    mContainer.setColCount(UIConfig.getRow());
    // 动态设置Container每页的行数为4行
    mContainer.setRowCount(UIConfig.getLine());
    mContainer.setBackgroundColor(UIConfig.getBackgroundColor());
    pageIndicator.initViews(getApplicationContext());
    pageIndicator.setBackgroundColor(UIConfig.getBackgroundColor());
    mainView.setBackgroundColor(UIConfig.getBackgroundColor());

    RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) pageIndicator.getLayoutParams();
    rlp.height = (int) UIConfig.getPageIndicatorScaleHight();
    pageIndicator.setLayoutParams(rlp);
    // 初始化Container的Adapter
    IconAdapter mIconsAdapter =
        new IconAdapter(
            getApplicationContext(), mIconList, defIconUrl, widgetInfo, mEUExIconList, mContainer);
    // 设置Container添加删除Item的回调
    mContainer.setOnAddPage(this);
    // 设置Container页面换转的回调,比如自第一页滑动第二页
    mContainer.setOnPageChangedListener(this);
    // 设置Container编辑模式的回调,长按进入修改模式
    mContainer.setOnEditModeListener(this);
    // 设置Adapter
    mContainer.setSaAdapter(mIconsAdapter);
    // 调用refreView绘制所有的Item
    mContainer.refreView();
    mContainer.setEuexIconList(mEUExIconList);

    int pageSize = UIConfig.getLine() * UIConfig.getRow();
    int pageCount = (int) Math.ceil((float) mIconList.size() / (float) pageSize);
    pageIndicator.setTotalPageSize(pageCount);
    pageIndicator.setCurrentPage(0);
    mContainer.setPageIndicator(pageIndicator);
  }
  /**
   * @param width raw image width
   * @param height raw image height
   * @param screenWidth
   * @param pageIndex
   * @param pageCount
   */
  public void refreshPosition(
      int width, int height, int screenWidth, int screenHeight, int pageIndex, int pageCount) {
    if (screenWidth < screenHeight) {
      int drawWidth = 0;

      if (pageCount == 1) { // keep full screen width
        drawWidth = screenWidth;
        leftX = 0;
      } else if (width * pageCount <= screenWidth) { // image raw width is shorter
        drawWidth = Math.round((screenWidth * 1.0f) / pageCount);
        leftX = drawWidth * pageIndex;
      } else { // image raw width is longer
        drawWidth = width;
        leftX = Math.round(((screenWidth - drawWidth) * 1.0f * pageIndex) / (pageCount - 1));
      }

      lp.width = drawWidth + 1;
      lp.height = (int) (6 * getContext().getResources().getDisplayMetrics().density);

    } else {
      int drawHeight = 0;

      if (pageCount == 1) { // keep full screen width
        drawHeight = screenHeight;
        topY = 0;
      } else if (width * pageCount <= screenHeight) { // image raw width is shorter
        drawHeight = Math.round((screenHeight * 1.0f) / pageCount);
        topY = drawHeight * pageIndex;
      } else { // image raw width is longer
        drawHeight = width;
        topY = (screenHeight - drawHeight) * pageIndex / (pageCount - 1);
      }

      lp.width = (int) (6 * getContext().getResources().getDisplayMetrics().density);
      ;
      lp.height = drawHeight;
    }

    rectD.left = leftX;
    rectD.top = topY;
    rectD.right = leftX + lp.width;
    rectD.bottom = topY + lp.height;

    invalidate();
  }
Beispiel #10
0
 public void showBageViewCount(boolean visiable) {
   badgeView.setText("");
   RelativeLayout.LayoutParams params =
       (android.widget.RelativeLayout.LayoutParams) badgeView.getLayoutParams();
   params.height = (int) getContext().getResources().getDimension(R.dimen.main_tab_bageSize);
   params.width = (int) getContext().getResources().getDimension(R.dimen.main_tab_bageSize);
   badgeView.setLayoutParams(params);
   badgeView.setVisibility(visiable ? View.VISIBLE : View.GONE);
 }
Beispiel #11
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);
    }
  }
  @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);
  }
  @Override
  public void processProperties(KrollDict d) {
    tableView = new TiTableView(proxy.getTiContext(), (TableViewProxy) proxy);
    tableView.setOnItemClickListener(this);

    if (d.containsKey(TiC.PROPERTY_SEARCH)) {
      RelativeLayout layout = new RelativeLayout(proxy.getTiContext().getActivity());
      layout.setGravity(Gravity.NO_GRAVITY);
      layout.setPadding(0, 0, 0, 0);

      TiViewProxy searchView = (TiViewProxy) d.get(TiC.PROPERTY_SEARCH);
      TiUISearchBar searchBar =
          (TiUISearchBar) searchView.getView(proxy.getTiContext().getActivity());
      searchBar.setOnSearchChangeListener(tableView);
      searchBar.getNativeView().setId(102);

      RelativeLayout.LayoutParams p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.height = 52;

      layout.addView(searchBar.getNativeView(), p);

      p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.addRule(RelativeLayout.BELOW, 102);
      layout.addView(tableView, p);
      setNativeView(layout);
    } else {
      setNativeView(tableView);
    }

    if (d.containsKey(TiC.PROPERTY_FILTER_ATTRIBUTE)) {
      tableView.setFilterAttribute(TiConvert.toString(d, TiC.PROPERTY_FILTER_ATTRIBUTE));
    } else {
      // Default to title to match iPhone default.
      proxy.setProperty(TiC.PROPERTY_FILTER_ATTRIBUTE, TiC.PROPERTY_TITLE, false);
      tableView.setFilterAttribute(TiC.PROPERTY_TITLE);
    }

    boolean filterCaseInsensitive = true;
    if (d.containsKey(TiC.PROPERTY_FILTER_CASE_INSENSITIVE)) {
      filterCaseInsensitive = TiConvert.toBoolean(d, TiC.PROPERTY_FILTER_CASE_INSENSITIVE);
    }
    tableView.setFilterCaseInsensitive(filterCaseInsensitive);
    super.processProperties(d);
  }
 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 setLeftTopRightBottomWidthHeight(
     int left, int top, int right, int bottom, int w, int h) {
   MarginLeft = left;
   MarginTop = top;
   marginRight = right;
   marginBottom = bottom;
   lpH = h;
   lpW = w;
   lparams.width = lpW;
   lparams.height = lpH;
 }
Beispiel #16
0
 private void createBottomBanner(Context context) {
   mBottomBanner = new RelativeLayout(this.getContext());
   mBottomBanner.setBackgroundResource(R.drawable.stone_bg);
   RelativeLayout.LayoutParams bottomBannerLP =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   bottomBannerLP.width = LayoutUtil.getNavigationPanelWidth();
   bottomBannerLP.height = LayoutUtil.getGalleryBottomPanelHeight();
   bottomBannerLP.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   this.addView(mBottomBanner, bottomBannerLP);
 }
  /**
   * Show this SnackBar. Make sure it already attached to a parent view or this method will do
   * nothing.
   */
  public void show() {
    ViewGroup parent = (ViewGroup) getParent();
    if (parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING) return;

    if (parent instanceof FrameLayout) {
      LayoutParams params = (LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.gravity = Gravity.START | Gravity.BOTTOM;
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    } else if (parent instanceof RelativeLayout) {
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      params.addRule(RelativeLayout.ALIGN_PARENT_START);
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    }

    if (mInAnimationId != 0 && mState != STATE_SHOWN) {
      Animation anim = AnimationUtils.loadAnimation(getContext(), mInAnimationId);
      anim.setAnimationListener(
          new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
              setState(STATE_SHOWING);
              setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              setState(STATE_SHOWN);
              startTimer();
            }
          });
      startAnimation(anim);
    } else {
      setVisibility(View.VISIBLE);
      setState(STATE_SHOWN);
      startTimer();
    }
  }
 private void initView() {
   if (!dialogMode) {
     RelativeLayout mainRelLayout = (RelativeLayout) findViewByResName("mainRelLayout");
     RelativeLayout.LayoutParams lp =
         (RelativeLayout.LayoutParams) mainRelLayout.getLayoutParams();
     lp.setMargins(0, 0, 0, 0);
     lp.height = RelativeLayout.LayoutParams.MATCH_PARENT;
     mainRelLayout.setLayoutParams(lp);
   }
   initTitleView();
   initBodyView();
   initImageListView();
 }
 /**
  * 根据分辨率设置透明按钮的大小
  *
  * @author [email protected] 2013-7-29 下午5:12:27
  * @param view
  * @return void
  */
 public static void resetRLBack(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.height = (int) (layoutParams.height * rote);
     layoutParams.width = (int) (layoutParams.width * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
 private void initData() {
   // TODO Auto-generated method stub
   uid = SharepreferenceUtil.readString(PreMainActivity.this, SharepreferenceUtil.fileName, "uid");
   finalBitmap = FinalBitmap.create(PreMainActivity.this);
   if (ContextUtil.getHeith(PreMainActivity.this) <= 480) {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 60);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 800) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 140);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 860) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 150);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 960) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 180);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "m";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 1280) {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 200);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "m";
   } else {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 210);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "h";
   }
   RelativeLayout.LayoutParams linearParams =
       (RelativeLayout.LayoutParams) fl_ad.getLayoutParams();
   linearParams.width = ContextUtil.getWidth(PreMainActivity.this);
   linearParams.height = linearParams.width / 2;
   fl_ad.setLayoutParams(linearParams);
   BitMapUtil.getImgOpt(PreMainActivity.this, finalBitmap, mJazzy, R.drawable.os_login_topicon);
 }
 // by jmpessoa
 public void setLayoutAll(int idAnchor) {
   lparams.width = lpW;
   lparams.height = lpH;
   lparams.setMargins(MarginLeft, MarginTop, marginRight, marginBottom);
   if (idAnchor > 0) {
     for (int i = 0; i < countAnchorRule; i++) {
       lparams.addRule(lparamsAnchorRule[i], idAnchor);
     }
   }
   for (int j = 0; j < countParentRule; j++) {
     lparams.addRule(lparamsParentRule[j]);
   }
   setLayoutParams(lparams);
 }
 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();
 }
 private void initScrollView(View root) {
   mItemHScrollView = (ItemHScrollView) root.findViewById(R.id.typeTab);
   RelativeLayout.LayoutParams params =
       (RelativeLayout.LayoutParams) mItemHScrollView.getLayoutParams();
   params.height = (int) (ScreenAdapter.getInstance(null).getHeadHeight() * 0.7f);
   mItemHScrollView.requestLayout();
   mItemHScrollView.setPositionOffset(0);
   mItemHScrollView.setOnItemClickListener(
       new ItemHScrollView.OnItemClickListener() {
         @Override
         public void onItemClick(ViewGroup parent, View view, int position) {
           mViewPager.setCurrentItem(position);
         }
       });
 }
  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);
    }
  }
Beispiel #25
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);
 }
  void updateBarProgress(boolean increase) {
    RelativeLayout.LayoutParams params = (LayoutParams) progressView.getLayoutParams();

    params.width = increase ? (params.width + delta) : (params.width - delta);
    params.height = getHeight();

    if (params.width > getWidth()) {
      params.width = getWidth();
    } else if (params.width < 0) {
      params.width = 0;
    }
    progressView.setLayoutParams(params);
    progress = (max - min) * params.width / getWidth();
    if ((increase && progress > pendingProgress) || (!increase && progress < pendingProgress)) {
      progress = pendingProgress;
    }
  }
  private void addpartialView(int index) {
    ViewBundle spot = gridBundle.get(index);
    if (spot == null) return; // should not be
    View displayed = spot.displayed;
    if (displayed == null) return;

    RelativeLayout.LayoutParams rlp = spot.rlp;
    int x = index % col;
    int y = index / col;
    rlp.leftMargin = x * colStep;
    rlp.topMargin = y * rowStep;
    rlp.height = (int) (rowStep * 1.1);
    rlp.width = colStep;

    ViewGroup vg = (ViewGroup) displayed.getParent();
    if (vg != null) vg.removeView(displayed);
    super.addView(displayed, rlp);
  }
  private void setProgress(int n) {

    if (vertical) {
      int w = (int) (((getHeight() / 100.0) * n) + 0.5);
      RelativeLayout.LayoutParams params =
          (RelativeLayout.LayoutParams) mBatteryBarLayout.getLayoutParams();

      params.height = w;
      mBatteryBarLayout.setLayoutParams(params);

    } else {
      Log.e(TAG, "width: " + getWidth());
      int w = (int) (((getWidth() / 100.0) * n) + 0.5);
      RelativeLayout.LayoutParams params =
          (RelativeLayout.LayoutParams) mBatteryBarLayout.getLayoutParams();
      params.width = w;
      mBatteryBarLayout.setLayoutParams(params);
    }
  }
        public void onClick(View view) {
          restorableFiles = util.findRestorableFiles();

          prepForModal();
          alertText.setVisibility(View.VISIBLE);
          alertModal.setVisibility(View.VISIBLE);

          if (restorableFiles.size() > 0) {
            alertCancel.setVisibility(View.VISIBLE);
            alertCancel.setOnClickListener(dismissModal);
            alertText.setText("Which file would you like to backup from?");

            alertListOne.setVisibility(View.VISIBLE);
            findViewById(R.id.object_selector_modal_list_one_header).setVisibility(View.GONE);
            ListView modalList = (ListView) findViewById(R.id.modal_list_one);
            modalList.setAdapter(
                new ArrayAdapter<String>(
                    BackupRestoreScreen.this,
                    settingsRef.getSearchModalListLayout(),
                    R.id.filter_option,
                    restorableFiles));
            modalList.setOnItemClickListener(fileSelected);

            Display display =
                ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
            int windowHeight = display.getHeight();
            RelativeLayout.LayoutParams listOneParams =
                (RelativeLayout.LayoutParams) alertListOne.getLayoutParams();
            if (listOneParams.height > (int) windowHeight * 0.6f) {
              listOneParams.height = (int) (windowHeight * 0.6f);
              alertListOne.setLayoutParams(listOneParams);
            }
          } else {
            alertOk.setVisibility(View.VISIBLE);
            String defaultDirectory = util.getDefaultDirectoryPath();
            alertText.setText(
                "There were no restorable .maol files found in the default directory. \n\n"
                    + "If you have a backup (.maol) file please place it in the directory "
                    + defaultDirectory);
            alertOk.setOnClickListener(dismissModal);
          }
        }
  @SuppressWarnings("deprecation")
  @Override
  protected void setUpView() {
    // 如果有topicID 则设置上
    Intent intent = getIntent();
    if (intent.hasExtra(INTENT_TOPIC_ID)) {
      topicId = intent.getIntExtra(INTENT_TOPIC_ID, 0);
    } else {
      setBarText("发表新动态");
    }
    // 如果有圈子名称
    if (intent.hasExtra(INTENT_TOPIC_NAME)) {
      topicName = intent.getStringExtra(INTENT_TOPIC_NAME);
      if (topicName.length() > 8) {
        topicName = topicName.substring(0, 8) + "...";
      }
      setBarText("发表至“" + topicName + "”");
    }

    // 设置初始间隔
    MarginLayoutParams oriLp = (MarginLayoutParams) addImageView.getLayoutParams();
    oriMarginLeft = oriLp.leftMargin;
    // 设置图片大小
    RelativeLayout.LayoutParams rlParams =
        (RelativeLayout.LayoutParams) addImageView.getLayoutParams();
    rlParams.height =
        rlParams.width =
            (getWindowManager().getDefaultDisplay().getWidth() - space * 3 - oriMarginLeft * 2) / 4;
    addImageView.setLayoutParams(rlParams);
    // 添加完成按钮
    addRightBtn("完成");
    locationString = "";
    // bitmap初始化
    headImageOptions =
        new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .cacheOnDisk(false)
            .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
  }