Exemplo n.º 1
0
  /**
   * 设置控件位置大小(主方法)
   *
   * @author ren
   */
  protected void postView(int w, int h) {

    // 背景大小
    LayoutParams para1;
    para1 = backImg.getLayoutParams();
    para1.height = w / 3;
    para1.width = w;
    backImg.setLayoutParams(para1);
    // 头像大小
    para1 = userHead.getLayoutParams();
    para1.height = (int) (1.01 * 4 * w / 18);
    para1.width = (int) (1.01 * 4 * w / 18);
    userHead.setLayoutParams(para1);

    // 头像大小
    para1 = hb1.getLayoutParams();
    para1.height = (int) (1.04 * 4 * w / 18);
    para1.width = (int) (1.04 * 4 * w / 18);
    hb1.setLayoutParams(para1);

    // 基本信息(按顺序)
    para(sign1);
    para(nickname1);
    para(realname1);
    para(sex1);
    para(xi1);
    para(grade1);
    para(say1);
    para(mail1);
    para(tele1);
    para(qq1);
  }
Exemplo n.º 2
0
  /** 加载页面 */
  private void initView() {
    /*头部标题*/
    myCommonTitle = (MyCommonTitle) findViewById(R.id.aci_mytitle);
    myCommonTitle.setTitle("喜刷刷");
    myCommonTitle.setBackBtnVisible(false);
    myCommonTitle.setLisener(null, this);

    container = (ScrollView) findViewById(R.id.container);

    viewPager = (AutoScrollViewPager) findViewById(R.id.index_slider); // 轮播图
    tv_news_more = (LinearLayout) findViewById(R.id.tv_index_gift); // 新闻更多
    index_list = (AutoListView) findViewById(R.id.index_list); // 新闻资讯
    index_list.setOnItemClickListener(this);
    index_gift = (LinearLayout) findViewById(R.id.index_gift); // 中间三大模块(即时,永久,兴趣)

    index_image1 = (ImageView) findViewById(R.id.index_image1); // 即时红包
    index_image2 = (ImageView) findViewById(R.id.index_image2); // 永久红包
    index_image3 = (ImageView) findViewById(R.id.index_image3); // 兴趣标签

    LayoutParams pageParms = viewPager.getLayoutParams();
    pageParms.width = Tools.M_SCREEN_WIDTH;
    pageParms.height = Tools.M_SCREEN_WIDTH * 2 / 5;

    LayoutParams imagelayout = index_gift.getLayoutParams();
    imagelayout.width = Tools.M_SCREEN_WIDTH;
    imagelayout.height = Tools.M_SCREEN_WIDTH * 11 / 30;
    badgeView1 = new BadgeView(IndexActivity.this, index_image1);
    badgeView1.setText("0");
    // badgeView1.hide();
    badgeView2 = new BadgeView(IndexActivity.this, index_image2);
    badgeView2.setText("0");
    // badgeView2.hide();

    viewPager.setInterval(2000);
    viewPager.startAutoScroll();

    viewPager.setOnPageChangeListener(
        new OnPageChangeListener() {
          public void onPageSelected(int position) {
            // 回调view
            uihandler.obtainMessage(0, position).sendToTarget();
          }

          public void onPageScrolled(int position, float positionOffset, int positionOffsetPx) {}

          public void onPageScrollStateChanged(int position) {}
        });

    setListener(index_image1, index_image2, index_image3, tv_news_more);
  }
Exemplo n.º 3
0
 public void resetViewWidth(View view) {
   if (view == null) return;
   LayoutParams params = view.getLayoutParams();
   if (params != null) {
     if (params.width == 0) {
       view.measure(
           MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
           MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
       params.width = (int) (view.getMeasuredWidth() * ratio);
     } else {
       params.width *= ratio;
     }
     view.setLayoutParams(params);
   }
 }
Exemplo n.º 4
0
  /**
   * Set the display options
   *
   * @param layout
   *     <ul>
   *       <li>{@link #VIDEO_LAYOUT_ORIGIN}
   *       <li>{@link #VIDEO_LAYOUT_SCALE}
   *       <li>{@link #VIDEO_LAYOUT_STRETCH}
   *       <li>{@link #VIDEO_LAYOUT_ZOOM}
   *     </ul>
   *
   * @param aspectRatio video aspect ratio, will audo detect if 0.
   */
  public void setVideoLayout(int layout) {
    LayoutParams lp = getLayoutParams();
    Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
    int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
    float windowRatio = windowWidth / (float) windowHeight;
    int sarNum = mVideoSarNum;
    int sarDen = mVideoSarDen;
    if (mVideoHeight > 0 && mVideoWidth > 0) {
      float videoRatio = ((float) (mVideoWidth)) / mVideoHeight;
      if (sarNum > 0 && sarDen > 0) videoRatio = videoRatio * sarNum / sarDen;
      mSurfaceHeight = mVideoHeight;
      mSurfaceWidth = mVideoWidth;

      if (VIDEO_LAYOUT_ORIGIN == layout
          && mSurfaceWidth < windowWidth
          && mSurfaceHeight < windowHeight) {
        lp.width = (int) (mSurfaceHeight * videoRatio);
        lp.height = mSurfaceHeight;
      } else if (layout == VIDEO_LAYOUT_ZOOM) {
        lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
        lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
      } else {
        boolean full = layout == VIDEO_LAYOUT_STRETCH;
        lp.width =
            (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
        lp.height =
            (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
      }
      setLayoutParams(lp);
      getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
      DebugLog.dfmt(
          TAG,
          "VIDEO: %dx%dx%f[SAR:%d:%d], Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f",
          mVideoWidth,
          mVideoHeight,
          videoRatio,
          mVideoSarNum,
          mVideoSarDen,
          mSurfaceWidth,
          mSurfaceHeight,
          lp.width,
          lp.height,
          windowWidth,
          windowHeight,
          windowRatio);
    }
    mVideoLayout = layout;
  }
Exemplo n.º 5
0
  /**
   * 重新计算view的宽高
   *
   * @param view
   * @param horizontalRatio
   * @param verticalRatio
   * @return
   */
  public static boolean resizeWidthAndHeight(
      View view, float horizontalRatio, float verticalRatio) {
    if (view == null) return false;
    Object tag = view.getTag();
    if (tag instanceof String) {
      String tagString = (String) tag;
      if ("ignoreSize".equals(tagString)) {
        return true;
      }
    }
    LayoutParams params = view.getLayoutParams();
    if (params != null) {
      int width = params.width;
      int height = params.height;
      if (params.width != LayoutParams.MATCH_PARENT && params.width != LayoutParams.WRAP_CONTENT) {
        width = (int) (width * horizontalRatio);
        if (width > 1) params.width = width;
      }
      if (params.height != LayoutParams.MATCH_PARENT
          && params.height != LayoutParams.WRAP_CONTENT) {
        height = (int) (height * verticalRatio);
        if (height > 1) params.height = height;
      }
      view.setLayoutParams(params);
    }

    return true;
  }
  public void gridviewInit() {
    GridAdapter adapter = new GridAdapter(this);
    adapter.setSelectedPosition(0);
    int size = 0;
    if (bmp.size() < 6) {
      size = bmp.size() + 1;
    } else {
      size = bmp.size();
    }
    GridView gridview = (GridView) findViewById(R.id.onlinedebug_showrecord_gridview);
    LayoutParams params = gridview.getLayoutParams();
    final int width = size * (int) (20 * 9.4f);
    params.width = width;
    gridview.setLayoutParams(params);
    gridview.setColumnWidth((int) (20 * 9.4f));
    gridview.setStretchMode(GridView.NO_STRETCH);
    gridview.setNumColumns(size);
    gridview.setAdapter(adapter);
    gridview.setOnItemClickListener(this);

    final HorizontalScrollView hsvSelectImg =
        (HorizontalScrollView) findViewById(R.id.onlinedebug_showrecord_horizontalscrollview);
    hsvSelectImg
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new OnPreDrawListener() {
              public boolean onPreDraw() {
                hsvSelectImg.scrollTo(width, 0);
                hsvSelectImg.getViewTreeObserver().removeOnPreDrawListener(this);
                return false;
              }
            });
  }
  /**
   * Zooms in or out of the board by scalling the size of each Box
   *
   * @param big increase or decrease the size
   */
  public void resizeMe(int big) {
    double resizeButton = 0.0;
    double resizeText = 0.0;
    boolean myCondition = false;
    if (big == 0) {
      resizeButton = 1.25;
      resizeText = 0.3125;
      myCondition = true;
    } else {
      resizeButton = 0.8;
      resizeText = 0.3125;
      myCondition = false;
    }

    for (int x = 0; x < this.getX(); ++x) {
      for (int y = 0; y < this.getY(); ++y) {
        Button change = this.board[x][y];
        LayoutParams params = change.getLayoutParams();

        if (((change.getHeight() * resizeButton > 70.0) && !myCondition)
            || ((change.getHeight() * resizeButton < 130.0) && myCondition)) {
          params.height = (int) (change.getHeight() * resizeButton);
          params.width = (int) (change.getWidth() * resizeButton);
          change.setLayoutParams(params);
          change.setTextSize((float) (params.height * resizeText));
        }
      }
    }
  }
  @SuppressLint("NewApi")
  private void updateWidget(int appWidgetId) {
    NoteWidget noteWidget = getNoteWidgetForId(appWidgetId);
    if (noteWidget.width == 0 || noteWidget.height == 0) {
      updateNoteWidgetSize(appWidgetId);
    }

    LayoutParams lp = noteWidget.view.getLayoutParams();
    lp.width = noteWidget.width;
    lp.height = noteWidget.height;
    noteWidget.view.setLayoutParams(lp);

    String text = NoteStorage.getNote(this, appWidgetId);
    applyNoteViewAttrs(this, noteWidget.view, text);
    noteWidget.view.setTextColor(Color.WHITE);

    RemoteViews views = new RemoteViews(getPackageName(), R.layout.appwidget_note);
    Bitmap viewImage = getViewImage(noteWidget.view);
    views.setImageViewBitmap(R.id.appwidget_note, viewImage);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
      views.setContentDescription(R.id.appwidget_note, text);
    }

    Intent configIntent =
        new Intent(this, ConfigActivity.class)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    views.setOnClickPendingIntent(
        R.id.appwidget_note, PendingIntent.getActivity(this, appWidgetId, configIntent, 0));

    getAppWidgetManager().updateAppWidget(appWidgetId, views);

    viewImage.recycle();
  }
Exemplo n.º 9
0
 private void initControls() {
   // init
   mContainer = (RelativeLayout) findViewById(R.id.activity_scan_code_capture_containter);
   mCropLayout = (RelativeLayout) findViewById(R.id.activity_scan_code_capture_crop_layout);
   mEditOrder = (EditText) findViewById(R.id.activity_scan_code_et_bar_code);
   Button mBtnAddOrder = (Button) findViewById(R.id.activity_scan_code_bt_add);
   Button mBtnLookOrder = (Button) findViewById(R.id.activity_scan_code_bt_look);
   Button mBtnOrderComplete = (Button) findViewById(R.id.activity_scan_code_bt_complete);
   mTextScanCount = (TextView) findViewById(R.id.activity_scan_code_tv_scan_order_count);
   mTextOrderNum = (TextView) findViewById(R.id.activity_scan_code_tv_scan_order_number);
   TextView mTextTitle = (TextView) findViewById(R.id.common_view_title_text);
   ImageView mImgBack = (ImageView) findViewById(R.id.common_view_title_img);
   mImgFlash = (ImageView) findViewById(R.id.common_view_title_img_menu);
   // init ui data;
   mEditOrder.setHint(String.format(getString(R.string.barcode_hint), PreferencesUtil.ordtitle));
   mEditOrder.setTransformationMethod(new AllCapTransformationMethod());
   mEditOrder.setKeyListener(new MyNumberKeyListener());
   mBtnLookOrder.setText(
       String.format(getString(R.string.barcode_record), PreferencesUtil.ordtitle));
   mTextTitle.setText(mNewOrder.getBtnname());
   mImgFlash.setVisibility(View.VISIBLE);
   LayoutParams lp = mImgFlash.getLayoutParams();
   lp.width = UtilsAndroid.UI.dip2px(this, 40);
   lp.height = UtilsAndroid.UI.dip2px(this, 40);
   mImgFlash.setLayoutParams(lp);
   mImgFlash.setImageResource(R.drawable.flash_light_white);
   mTextScanCount.setText(
       String.format(getString(R.string.barcode_total), PreferencesUtil.ordtitle, 0));
   // init ui listener;
   mImgBack.setOnClickListener(this);
   mBtnAddOrder.setOnClickListener(this);
   mImgFlash.setOnClickListener(this);
   mBtnLookOrder.setOnClickListener(this);
   mBtnOrderComplete.setOnClickListener(this);
 }
Exemplo n.º 10
0
  public boolean handleMeasuredStateTooSmall() {
    boolean needsSecondMeasure = false;
    int i = 0;

    for (int N = this.mHost.getChildCount(); i < N; ++i) {
      View view = this.mHost.getChildAt(i);
      LayoutParams params = view.getLayoutParams();
      if (Log.isLoggable("PercentLayout", 3)) {
        Log.d("PercentLayout", "should handle measured state too small " + view + " " + params);
      }

      if (params instanceof PercentLayoutHelper.PercentLayoutParams) {
        PercentLayoutHelper.PercentLayoutInfo info =
            ((PercentLayoutHelper.PercentLayoutParams) params).getPercentLayoutInfo();
        if (info != null) {
          if (shouldHandleMeasuredWidthTooSmall(view, info)) {
            needsSecondMeasure = true;
            params.width = -2;
          }

          if (shouldHandleMeasuredHeightTooSmall(view, info)) {
            needsSecondMeasure = true;
            params.height = -2;
          }
        }
      }
    }

    if (Log.isLoggable("PercentLayout", 3)) {
      Log.d("PercentLayout", "should trigger second measure pass: " + needsSecondMeasure);
    }

    return needsSecondMeasure;
  }
Exemplo n.º 11
0
 public void setSplitActionBar(boolean z) {
   if (this.d != z) {
     if (this.b != null) {
       LayoutParams layoutParams = new LayoutParams(-2, -1);
       ViewGroup viewGroup;
       if (z) {
         this.b.m1681a(getContext().getResources().getDisplayMetrics().widthPixels, true);
         this.b.m1680a(Integer.MAX_VALUE);
         layoutParams.width = -1;
         layoutParams.height = this.f;
         this.a = (ActionMenuView) this.b.m1678a((ViewGroup) this);
         this.a.setBackgroundDrawable(this.f1088p);
         viewGroup = (ViewGroup) this.a.getParent();
         if (viewGroup != null) {
           viewGroup.removeView(this.a);
         }
         this.c.addView(this.a, layoutParams);
       } else {
         this.a = (ActionMenuView) this.b.m1678a((ViewGroup) this);
         this.a.setBackgroundDrawable(null);
         viewGroup = (ViewGroup) this.a.getParent();
         if (viewGroup != null) {
           viewGroup.removeView(this.a);
         }
         addView(this.a, layoutParams);
       }
     }
     super.setSplitActionBar(z);
   }
 }
Exemplo n.º 12
0
  /**
   * Creates an wheelView (Dialog) so the user can set the date and time. Requires wheel_src library
   * project.
   *
   * @param Context to show in
   * @param Time to show in milliseconds
   * @return Dialog
   */
  public Dialog showDateDialog(Context in, long timeinms) {
    Dialog timeDialog = new Dialog(in);
    timeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    timeDialog.setContentView(R.layout.time2_layout);
    LayoutParams params = timeDialog.getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    timeDialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    boolean tf = false;
    tf = sp.getBoolean("prefs_time_24", true);

    int nhours = 23;
    int startH = 0;
    if (tf) {
      nhours = 23;
      startH = 0;
    } else {
      startH = 1;
      nhours = 12;
    }

    final WheelView hours = (WheelView) timeDialog.findViewById(R.id.hour);
    NumericWheelAdapter hourAdapter = new NumericWheelAdapter(TimeClock.this, startH, nhours);
    hourAdapter.setItemResource(R.layout.wheel_text_item);
    hourAdapter.setItemTextResource(R.id.text);
    hours.setViewAdapter(hourAdapter);

    final WheelView mins = (WheelView) timeDialog.findViewById(R.id.mins);
    NumericWheelAdapter minAdapter = new NumericWheelAdapter(TimeClock.this, 0, 59, "%02d");
    minAdapter.setItemResource(R.layout.wheel_text_item);
    minAdapter.setItemTextResource(R.id.text);
    mins.setViewAdapter(minAdapter);
    mins.setCyclic(true);

    final WheelView ampm = (WheelView) timeDialog.findViewById(R.id.ampm);
    ArrayWheelAdapter<String> ampmAdapter =
        new ArrayWheelAdapter<String>(TimeClock.this, new String[] {"AM", "PM"});
    ampmAdapter.setItemResource(R.layout.wheel_text_item);
    ampmAdapter.setItemTextResource(R.id.text);
    ampm.setViewAdapter(ampmAdapter);

    // set current time
    Calendar calendar = Calendar.getInstance(Locale.US);
    calendar.setTimeInMillis(timeinms);

    mins.setCurrentItem(calendar.get(Calendar.MINUTE));

    ampm.setCurrentItem(calendar.get(Calendar.AM_PM));
    if (tf) {
      hours.setCurrentItem(calendar.get(Calendar.HOUR_OF_DAY));
      ampm.setVisibility(View.GONE);
    } else {
      hours.setCurrentItem(calendar.get(Calendar.HOUR) - 1);
      ampm.setVisibility(View.VISIBLE);
    }

    final WheelView day = (WheelView) timeDialog.findViewById(R.id.day);
    day.setViewAdapter(new DayArrayAdapter(TimeClock.this, calendar));
    day.setCurrentItem(20);
    return timeDialog;
  }
Exemplo n.º 13
0
  private void initSearchComponent() {
    //		etSearch = (EditText) mView.findViewById(R.id.etHomeSearch);
    etSearch = new EditText(getActivity());
    Drawable drawable = getResources().getDrawable(R.drawable.search_white);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    etSearch.setCompoundDrawables(drawable, null, null, null);
    etSearch.setTypeface(StringUtil.getTypeFaceByRegular(getActivity()));
    etSearch.setFocusable(true);
    etSearch.setHint(R.string.eventName);
    etSearch.setFocusableInTouchMode(true);
    LayoutParams params = etSearch.getLayoutParams();
    if (params == null) {
      params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }
    params.height = LayoutParams.WRAP_CONTENT;
    params.width = LayoutParams.MATCH_PARENT;
    etSearch.setLayoutParams(params);
    LinearLayout llSearch = new LinearLayout(getActivity());
    llSearch.setPadding(3, 3, 3, 3);
    llSearch.addView(etSearch);
    plvManage.getRefreshableView().addHeaderView(llSearch);
    etSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            mManageAdapter.filterEventsByText(s.toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
Exemplo n.º 14
0
 @Override
 public int getWidth(int tabWidth) {
   if (width <= 0) {
     layoutParams.width = tabWidth;
     return tabWidth;
   }
   return width;
 }
Exemplo n.º 15
0
 private void initTabLine() {
   Display display = getWindow().getWindowManager().getDefaultDisplay(); // 获取屏幕的大小
   DisplayMetrics displayMetrics = new DisplayMetrics();
   display.getMetrics(displayMetrics);
   widthScreen1_4 = displayMetrics.widthPixels / 4; // 整个屏幕分为四部分;注意这里的1/4并不是TabLine的宽度
   LayoutParams lp = mTabLine.getLayoutParams();
   lp.width = widthScreen1_4;
   mTabLine.setLayoutParams(lp);
 }
    @Override
    public void setSurfaceLayout(int width, int height) {

      LayoutParams lp = view.getLayoutParams();
      lp.width = width;
      lp.height = height;
      view.setLayoutParams(lp);
      view.invalidate();
    }
Exemplo n.º 17
0
 /**
  * 设置视图宽高
  *
  * @param view
  * @param width
  * @param height
  * @return
  */
 public static boolean setViewSize(View view, int width, int height) {
   LayoutParams params = null;
   if (view instanceof ViewGroup) params = view.getLayoutParams();
   if (params == null) params = ((View) (view.getParent())).getLayoutParams();
   if (params == null) return false;
   params.width = width;
   params.height = height;
   view.setLayoutParams(params);
   return true;
 }
Exemplo n.º 18
0
 /**
  * Set the display options
  *
  * @param layout
  *     <ul>
  *       <li>{@link #VIDEO_LAYOUT_ORIGIN}
  *       <li>{@link #VIDEO_LAYOUT_SCALE}
  *       <li>{@link #VIDEO_LAYOUT_STRETCH}
  *       <li>{@link #VIDEO_LAYOUT_ZOOM}
  *     </ul>
  *
  * @param aspectRatio video aspect ratio, will audo detect if 0.
  */
 public void setVideoLayout(int layout, float aspectRatio) {
   LayoutParams lp = getLayoutParams();
   DisplayMetrics disp = mContext.getResources().getDisplayMetrics();
   int windowWidth = disp.widthPixels, windowHeight = disp.heightPixels;
   Log.d(
       "VideoView width and height",
       " width ============== " + windowWidth + ", height ============== " + windowHeight);
   float windowRatio = windowWidth / (float) windowHeight;
   float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
   mSurfaceHeight = mVideoHeight;
   mSurfaceWidth = mVideoWidth;
   if (VIDEO_LAYOUT_ORIGIN == layout
       && mSurfaceWidth < windowWidth
       && mSurfaceHeight < windowHeight) {
     lp.width = (int) (mSurfaceHeight * videoRatio);
     lp.height = mSurfaceHeight;
   } else if (layout == VIDEO_LAYOUT_ZOOM) {
     lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
     lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
   } else {
     boolean full = layout == VIDEO_LAYOUT_STRETCH;
     lp.width =
         (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
     lp.height =
         (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
   }
   setLayoutParams(lp);
   getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
   Log.d(
       "VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f",
       mVideoWidth,
       mVideoHeight,
       mVideoAspectRatio,
       mSurfaceWidth,
       mSurfaceHeight,
       lp.width,
       lp.height,
       windowWidth,
       windowHeight,
       windowRatio);
   mVideoLayout = layout;
   mAspectRatio = aspectRatio;
 }
Exemplo n.º 19
0
 private void setParams() {
   LayoutParams lay = this.getWindow().getAttributes();
   DisplayMetrics dm = new DisplayMetrics();
   this.getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
   Rect rect = new Rect();
   View view = getWindow().getDecorView();
   view.getWindowVisibleDisplayFrame(rect);
   lay.height = dm.heightPixels - rect.top;
   lay.width = dm.widthPixels;
 }
Exemplo n.º 20
0
 @Override
 public View getView(final int position, final View convertView, final ViewGroup parent) {
   View view = null;
   if (isSectionHeaderPosition(position)) {
     final Section section = mSections.get(position);
     LayoutParams layoutParams;
     switch (section.type) {
       case TYPE_HEADER:
         view = handleSectionHeaderView(convertView, section, parent);
         layoutParams = view.getLayoutParams();
         layoutParams.width = getHeaderSize();
         view.setLayoutParams(layoutParams);
         view.setVisibility(View.VISIBLE);
         break;
       case TYPE_HEADER_FILLER:
         view = convertView;
         if (view == null) {
           view = new View(mContext);
           view.setLayoutParams(new AbsListView.LayoutParams(0, mHeaderHeight));
         }
         break;
       case TYPE_FILLER:
         view = convertView;
         if (view == null) {
           view = new View(mContext);
           view.setLayoutParams(new AbsListView.LayoutParams(0, mNormalCellHeight));
         }
         final boolean lastInRow = position % mNumColumns == mNumColumns - 1;
         layoutParams = view.getLayoutParams();
         layoutParams.width = lastInRow ? LayoutParams.MATCH_PARENT : 0;
         view.setLayoutParams(layoutParams);
         break;
     }
   } else {
     view = mBaseAdapter.getView(sectionedPositionToPosition(position), convertView, parent);
     final LayoutParams layoutParams = view.getLayoutParams();
     layoutParams.height = mNormalCellHeight;
     layoutParams.width = mColumnWidth;
     view.setLayoutParams(layoutParams);
   }
   return view;
 }
Exemplo n.º 21
0
 private void todo() {
   int x = new Random().nextInt(99999);
   mInt = Integer.toString(x);
   mPaint.setTextSize(mTextSize);
   mPaint.getTextBounds(mInt, 0, mInt.length(), mBound);
   LayoutParams par = getLayoutParams(); // 重新设置宽高
   par.width = getPaddingLeft() + mBound.width() + getPaddingRight();
   par.height = getPaddingTop() + mBound.height() + getPaddingBottom();
   setLayoutParams(par);
   postInvalidate();
 }
Exemplo n.º 22
0
 /**
  * 根据屏幕宽度设置传入View的宽度
  *
  * @param view
  * @param designedWidthResId UI设计的高度资源ID
  * @return 是否成功设置
  */
 public static boolean setWidth(View view, int designedWidthResId) {
   float designedWidth =
       BaseApplication.getAppContext().getResources().getDimension(designedWidthResId);
   LayoutParams params = null;
   if (view instanceof ViewGroup) params = view.getLayoutParams();
   if (params == null) params = ((View) (view.getParent())).getLayoutParams();
   if (params == null) return false;
   params.width = (int) (designedWidth * SCALE_RATIO_HORIZONTAL);
   view.setLayoutParams(params);
   return true;
 }
Exemplo n.º 23
0
 public void setTabContainer(ScrollingTabContainerView tabView) {
   if (this.mTabContainer != null) {
     removeView(this.mTabContainer);
   }
   this.mTabContainer = tabView;
   if (tabView != null) {
     addView(tabView);
     LayoutParams lp = tabView.getLayoutParams();
     lp.width = -1;
     lp.height = -2;
     tabView.setAllowCollapse(false);
   }
 }
Exemplo n.º 24
0
  @Override
  public void setImageBitmap(Bitmap bm) {
    if (context != null && FacebookPhotoCommentsActivity.class.isInstance(context) && bm != null) {
      // reset photo_image size;
      int width = bm.getWidth();
      int height = bm.getHeight();
      int screenWidth =
          ((FacebookPhotoCommentsActivity) context)
              .getWindowManager()
              .getDefaultDisplay()
              .getWidth();
      int screenHeight =
          ((FacebookPhotoCommentsActivity) context)
              .getWindowManager()
              .getDefaultDisplay()
              .getHeight();

      if (screenWidth < screenHeight) {
        // portrait mode
        screenHeight = (screenWidth * height) / width;

        if (width < screenWidth) {
          LayoutParams params = this.getLayoutParams();
          params.width = screenWidth;
          params.height = screenHeight;
        }
      } else {
        // landspace mode
        screenWidth = (screenHeight * width) / height;
        if (width < screenWidth) {
          LayoutParams params = this.getLayoutParams();
          params.width = screenWidth;
          params.height = screenHeight;
        }
      }
    }
    super.setImageBitmap(bm);
    // reset PhotoCommentsActivity
  }
  public void updateLayoutParams(boolean inDialog) {
    LayoutParams layoutParams = getLayoutParams();
    DisplayMetrics metrics = getDisplayMetrics(getContext());
    log.debug("Maximum display resolution: {} X {}\n", metrics.widthPixels, metrics.heightPixels);
    if (inDialog) {
      metrics.widthPixels -= 40;
      metrics.heightPixels -= 40;
    }
    int[] params = getDisplayParameters(metrics.widthPixels, metrics.heightPixels);
    layoutParams.width = params[0];
    layoutParams.height = params[1];
    setLayoutParams(layoutParams);

    if (showing)
      nativeResize(metrics.widthPixels, metrics.heightPixels, params[0], params[1], 0, 0);
    else initDrawer(metrics.widthPixels, metrics.heightPixels, params[0], params[1], 0, 0);
  }
Exemplo n.º 26
0
  private void initview() {
    // TODO Auto-generated method stub
    back_btn = (LinearLayout) findViewById(R.id.back_btn);
    im_bg = (ImageView) findViewById(R.id.im_bg);
    tv_pre = (TextView) findViewById(R.id.tv_pre);
    tv_next = (TextView) findViewById(R.id.tv_next);
    et_name = (EditText) findViewById(R.id.et_name);
    et_hospital = (EditText) findViewById(R.id.et_hospital);
    et_keshi = (EditText) findViewById(R.id.et_keshi);
    et_zhicheng = (EditText) findViewById(R.id.et_zhicheng);
    et_liuyan = (EditText) findViewById(R.id.et_liuyan);

    LayoutParams params = (LayoutParams) im_bg.getLayoutParams();
    params.width = LayoutParams.MATCH_PARENT;
    params.height = 4 * width / 9;
    im_bg.setLayoutParams(params);
  }
Exemplo n.º 27
0
    public void fillLayoutParams(LayoutParams params, int widthHint, int heightHint) {
      this.mPreservedParams.width = params.width;
      this.mPreservedParams.height = params.height;
      if (this.widthPercent >= 0.0F) {
        params.width = (int) ((float) widthHint * this.widthPercent);
      }

      if (this.heightPercent >= 0.0F) {
        params.height = (int) ((float) heightHint * this.heightPercent);
      }

      if (Log.isLoggable("PercentLayout", 3)) {
        Log.d(
            "PercentLayout",
            "after fillLayoutParams: (" + params.width + ", " + params.height + ")");
      }
    }
Exemplo n.º 28
0
 protected void fixItemViewParams(IItemView<DATA_ITEM> itemView) {
   View v = itemView.toView();
   boolean changed = false;
   LayoutParams itemParams = v.getLayoutParams();
   if (itemParams != null) {
     if (itemParams.width <= 0 && itemParams.width != LayoutParams.MATCH_PARENT) {
       itemParams.width = LayoutParams.MATCH_PARENT;
       changed = true;
     }
   } else {
     itemParams =
         new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
     changed = true;
   }
   if (changed) {
     v.setLayoutParams(itemParams);
   }
 }
  private void openFullscreen() {
    mInFS = true;
    if (mComponents != null) {
      for (Iterator<View> i = mComponents.iterator(); i.hasNext(); ) {
        i.next().setVisibility(View.GONE);
      }
    }

    Point size = new Point();
    mActivity.getWindowManager().getDefaultDisplay().getSize(size);
    if (mLayout != null) {
      LayoutParams params = (LayoutParams) mLayout.getLayoutParams();
      params.width = LayoutParams.MATCH_PARENT;
      params.height = LayoutParams.MATCH_PARENT;
      mLayout.invalidate();
    }
    mPlayerView.setPlayerViewDimensions(size.x, size.y);
  }
Exemplo n.º 30
0
 protected void b(Drawable drawable) {
   if (drawable != null) {
     int intrinsicHeight = drawable.getIntrinsicHeight();
     int intrinsicWidth = drawable.getIntrinsicWidth();
     LayoutParams layoutParams = this.Bm.getLayoutParams();
     int max = Math.max(intrinsicHeight, intrinsicWidth);
     layoutParams.height = max;
     layoutParams.width = max;
     this.Bm.requestLayout();
     this.Bm.setScaleType(ScaleType.MATRIX);
     Matrix matrix = new Matrix();
     matrix.postTranslate(
         ((float) (layoutParams.width - intrinsicWidth)) / 2.0f,
         ((float) (layoutParams.height - intrinsicHeight)) / 2.0f);
     matrix.postRotate(
         fi(), ((float) layoutParams.width) / 2.0f, ((float) layoutParams.height) / 2.0f);
     this.Bm.setImageMatrix(matrix);
   }
 }