/**
   * 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));
        }
      }
    }
  }
Пример #2
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;
  }
Пример #3
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);
 }
  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;
              }
            });
  }
  @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();
  }
  @Override
  public void onBindViewHolder(final MyViewHolder holder, final int position) {
    LayoutParams lp = holder.tv.getLayoutParams();
    lp.height = mHeights.get(position);

    holder.tv.setLayoutParams(lp);
    holder.tv.setText(mDatas.get(position));

    // 如果设置了回调,则设置点击事件
    if (mOnItemClickLitener != null) {
      holder.itemView.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              int pos = holder.getLayoutPosition();
              mOnItemClickLitener.onItemClick(holder.itemView, pos);
            }
          });

      holder.itemView.setOnLongClickListener(
          new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              int pos = holder.getLayoutPosition();
              mOnItemClickLitener.onItemLongClick(holder.itemView, pos);
              removeData(pos);
              return false;
            }
          });
    }
  }
Пример #7
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);
   }
 }
  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;
  }
Пример #9
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;
  }
Пример #10
0
  protected void buildView() {
    final Context context = getContext();

    mProgressBar = new ProgressBar(context);
    final LayoutParams progressLayoutParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
    progressLayoutParams.gravity = Gravity.CENTER;
    mProgressBar.setLayoutParams(progressLayoutParams);
    mProgressBar.setId(INTERNAL_PROGRESS_ID);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);

    addView(mProgressBar);

    mIsLoading = false;

    mImageView = new ImageView(context);
    final LayoutParams imageViewLayoutParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
    imageViewLayoutParams.gravity = Gravity.CENTER;
    mImageView.setLayoutParams(imageViewLayoutParams);
    mImageView.setId(INTERNAL_IMAGEVIEW_ID);
    mImageView.setVisibility(View.VISIBLE);

    addView(mImageView);

    setLayoutParams(new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
  }
  @Override
  protected void onPostExecute(Bitmap bitmap) {
    if (isCancelled()) {
      bitmap = null;
    }

    if (imageViewReference != null) {
      final WaterfallFlowView imageView = imageViewReference.get();
      if (imageView != null) {
        if (bitmap != null) {
          int width = bitmap.getWidth(); // 获取真实宽高
          int height = bitmap.getHeight();

          LayoutParams lp = imageView.getLayoutParams();
          lp.height = (height * param.getItemWidth()) / width; // 调整高度
          imageView.setLayoutParams(lp);
          imageView.bitmap = bitmap;
          imageView.setImageBitmap(imageView.bitmap); // 将引用指定到同一个对象,方便销毁

          Handler h = imageView.getViewHandler();
          Message m =
              h.obtainMessage(this.param.what, this.param.getFlowId(), lp.height, imageView);
          h.sendMessage(m);
        }
      }
    }
  }
Пример #12
0
 @Override
 protected void onPostExecute(Bitmap bitmap) {
   // TODO Auto-generated method stub
   super.onPostExecute(bitmap);
   if (isCancelled()) {
     bitmap = null;
   }
   if (imageViewReference != null) {
     ImageView imageView = imageViewReference.get();
     if (imageView != null) {
       if (bitmap != null) {
         int width = bitmap.getWidth();
         int height = bitmap.getHeight();
         LayoutParams lp = imageView.getLayoutParams();
         lp.height = (height * item_width) / width;
         imageView.setLayoutParams(lp);
         imageView.setImageBitmap(bitmap);
         /*if (bitmap != null && !bitmap.isRecycled()) {
         	bitmap.recycle();
         	bitmap = null;
         }*/
       }
     }
   }
 }
Пример #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) {}
        });
  }
  private void setupChart(Typeface typeface) {
    LinearLayout chartLayout = (LinearLayout) findViewById(R.id.ll_grade_chart);
    LayoutParams params = chartLayout.getLayoutParams();
    if (originalHeightChartLayout < 0) {
      originalHeightChartLayout = params.height;
    }
    if (mGrade.nr_avaliations > 0) {
      params.height = originalHeightChartLayout;
      chartLayout.setLayoutParams(params);
      mRenderer = new LabelPercentRenderer();
      mSeries = new LabelCategorySeries(getString(R.string.concepts));

      mChartView = HelpChartFactory.getLabelPercentPieChartView(this, mSeries, mRenderer);

      mRenderer.setZoomButtonsVisible(false);
      mRenderer.setDisplayValues(false);
      mRenderer.setDisplayValuesAsPercent(false);
      mRenderer.setAntialiasing(true);
      mRenderer.setInScroll(false);

      mRenderer.setShowLabels(true);
      mRenderer.setShowLegend(false);

      mRenderer.setOnlyPercentToLabel(false);
      mRenderer.setAppendPercentToLabel(true);
      mRenderer.setTextTypeface(typeface);
      mRenderer.setClickEnabled(false);

      int size =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics());
      mRenderer.setLabelsTextSize(size);
      mRenderer.setLegendTextSize(size);

      mRenderer.setLabelsColor(getResources().getColor(android.R.color.black));
      String titleBase = getString(R.string.concept);
      if (mGrade.nr_A > 0) {
        addSliceToPie(titleBase + " A: ", mGrade.nr_A);
      }
      if (mGrade.nr_B > 0) {
        addSliceToPie(titleBase + " B: ", mGrade.nr_B);
      }
      if (mGrade.nr_C > 0) {
        addSliceToPie(titleBase + " C: ", mGrade.nr_C);
      }
      if (mGrade.nr_D > 0) {
        addSliceToPie(titleBase + " D: ", mGrade.nr_D);
      }

      mChartView.repaint();
      chartLayout.removeAllViews();
      chartLayout.addView(
          mChartView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    } else {
      params.height = 0;
      chartLayout.setLayoutParams(params);
    }
  }
Пример #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);
 }
Пример #16
0
 /**
  * 根据屏幕宽度设置传入View的高度
  *
  * @param view
  * @param height 像素值
  * @return 是否成功设置
  */
 public static boolean setViewHeight(View view, 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.height = height;
   view.setLayoutParams(params);
   return true;
 }
    @Override
    public void setSurfaceLayout(int width, int height) {

      LayoutParams lp = view.getLayoutParams();
      lp.width = width;
      lp.height = height;
      view.setLayoutParams(lp);
      view.invalidate();
    }
Пример #18
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;
 }
Пример #19
0
 private void updateViewSize(ImageView iconView) {
   int intrinsicWidth = iconView.getDrawable().getIntrinsicWidth();
   LayoutParams lp = iconView.getLayoutParams();
   if (intrinsicWidth > 0) {
     lp.height = lp.width * iconView.getDrawable().getIntrinsicHeight() / intrinsicWidth;
   } else {
     // If no intrinsic width, then just mke this a square.
     lp.height = lp.width;
   }
 }
 @Override
 public void onGlobalLayout() {
   if (waitingForExactHeaderHeight && dummyHeader.getHeight() > 0) {
     headerHeight = dummyHeader.getHeight();
     waitingForExactHeaderHeight = false;
     LayoutParams params = dummyHeader.getLayoutParams();
     params.height = headerHeight;
     dummyHeader.setLayoutParams(params);
   }
 }
Пример #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();
 }
Пример #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;
 }
Пример #23
0
 /**
  * 根据屏幕宽度设置传入View的高度
  *
  * @param view
  * @param designedHeightResId UI设计的高度资源ID(以像素为单位)
  * @return 是否成功设置
  */
 public static boolean setHeight(View view, int designedHeightResId) {
   if (view == null) return false;
   float designedHeight =
       BaseApplication.getAppContext().getResources().getDimension(designedHeightResId);
   LayoutParams params = null;
   if (view instanceof ViewGroup) params = view.getLayoutParams();
   if (params == null) params = ((View) (view.getParent())).getLayoutParams();
   if (params == null) return false;
   params.height = (int) (designedHeight * SCALE_RATIO_VERTICAL);
   view.setLayoutParams(params);
   return true;
 }
  // return a group view with a custom layout
  public View getGroupView(
      int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater infl =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView =
          infl.inflate(R.layout.row_custom_expandable_listview_adapter_group_layout, null);
    }

    TextView tv1 = (TextView) convertView.findViewById(R.id.tv1);
    TextView tv2 = (TextView) convertView.findViewById(R.id.tv2);
    TextView tv3 = (TextView) convertView.findViewById(R.id.tv3);
    TextView tv4 = (TextView) convertView.findViewById(R.id.tv4);

    // used to set the right hight for the fontsize so the text wont go off
    // screen
    TextView tvHeigth = (TextView) convertView.findViewById(R.id.textViewHeight);

    LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.LinearLayoutInsuline);

    tv1.setTextSize(fontSize);
    tv2.setTextSize(fontSize - 7);

    tv3.setTextSize(fontSize);
    tv4.setTextSize(fontSize - 7);

    LayoutParams params = tvHeigth.getLayoutParams();
    switch (displayMetrics) {
      case DisplayMetrics.DENSITY_HIGH:
        params.height = (5 * fontSize);
        break;
      default:
        params.height = (4 * fontSize);
        break;
    }
    tvHeigth.setLayoutParams(params);

    if (calculatedInsuline.equals("")) {
      ll.setVisibility(View.GONE);
    } else {
      ll.setVisibility(View.VISIBLE);
      tv1.setText(calculatedInsuline);
      tv2.setText(insulineRatio);
    }

    tv3.setText(defaultCalculated);
    tv4.setText(defaultCalculatedText);

    tv3.setBackgroundColor(getRightColor(defaultValue));

    return convertView;
  }
Пример #25
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    View connectionHeaderView = inflater.inflate(R.layout.connection_header, null);
    layout.addView(connectionHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    View bufferHeaderView = inflater.inflate(R.layout.fragment_buffer_header, null);
    layout.addView(bufferHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    ListView listView = new ListView(getActivity());
    listView.setId(android.R.id.list);
    listView.setDivider(null);
    listView.setStackFromBottom(true);
    listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
    listView.setSmoothScrollbarEnabled(false);
    //        listView.setCacheColorHint(Color.TRANSPARENT);

    LayoutParams params = new LayoutParams(MATCH_PARENT, 0);
    params.weight = 1;
    layout.addView(listView, params);
    View footerView = inflater.inflate(R.layout.fragment_buffer_footer, null);
    layout.addView(footerView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    ((TextView) footerView.findViewById(R.id.text_entry))
        .setOnEditorActionListener(
            new TextView.OnEditorActionListener() {
              public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (event != null && event.getAction() != KeyEvent.ACTION_DOWN) {
                  return false;
                }

                sendMessage();
                return true;
              }
            });

    footerView
        .findViewById(R.id.send_button)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                sendMessage();
              }
            });

    return layout;
  }
Пример #26
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);
   }
 }
Пример #27
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);
   }
 }
 @Override
 public void handleMessage(Message msg) {
   if (msg.what == 1) {
     if (msg.obj != null) {
       Bitmap drawable = (Bitmap) msg.obj;
       LayoutParams layoutParams = news_pic.getLayoutParams();
       int height = drawable.getHeight(); // 获取图片的高度.
       int width = drawable.getWidth(); // 获取图片的宽度
       layoutParams.height = (height * image_width) / width;
       news_pic.setLayoutParams(layoutParams);
       news_pic.setImageBitmap(drawable);
     } else {
       news_pic.setImageResource(R.drawable.default_image_position);
     }
   }
 }
Пример #29
0
 @Override
 public int getWidth(int tabWidth) {
   if (width <= 0) {
     layoutParams.width = tabWidth;
     return tabWidth;
   }
   return width;
 }
Пример #30
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 + ")");
      }
    }