示例#1
1
 public void setAction(String action) {
   if (action != null) {
     button.setText(action);
     button.setVisibility(View.VISIBLE);
     content.setPadding(
         content.getPaddingLeft(),
         0,
         (int) getResources().getDimension(R.dimen.carbon_paddingHalf),
         0);
   } else {
     content.setPadding(content.getPaddingLeft(), 0, content.getPaddingLeft(), 0);
     button.setVisibility(View.GONE);
   }
 }
示例#2
1
  public void backTopAndCenterWithAnimation() {
    mStepLayout.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 11) {
      float centerHeight =
          mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_center_move_top_height);
      ObjectAnimator centerAnimator =
          ObjectAnimator.ofFloat(mCenterLayoutParent, "y", -centerHeight, 0f);
      centerAnimator.setDuration(ANIMATION_TIME);
      centerAnimator.start();

      float topHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_top_height);
      ObjectAnimator topAnimator = ObjectAnimator.ofFloat(mFirstTopView, "y", -topHeight, 0f);
      topAnimator.setDuration(ANIMATION_TIME);
      topAnimator.start();

    } else {
      mFirstTopView.setVisibility(View.VISIBLE);

      float topHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_top_height);
      float bottomHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_bottom_height);
      mCenterLayoutParent.setPadding(
          mCenterLayoutParent.getPaddingLeft(),
          Math.round(topHeight),
          mCenterLayoutParent.getPaddingRight(),
          Math.round(bottomHeight));
    }
  }
示例#3
1
 public void setAboveOffset(int i) {
   //		RelativeLayout.LayoutParams params =
   // ((RelativeLayout.LayoutParams)mContent.getLayoutParams());
   //		params.setMargins(i, params.topMargin, params.rightMargin, params.bottomMargin);
   mContent.setPadding(
       i, mContent.getPaddingTop(), mContent.getPaddingRight(), mContent.getPaddingBottom());
 }
  private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

      View v = tabsContainer.getChildAt(i);

      v.setLayoutParams(defaultTabLayoutParams);
      v.setBackgroundResource(tabBackgroundResId);
      if (shouldExpand) {
        v.setPadding(0, 0, 0, 0);
        v.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0F));
      } else {
        v.setPadding(tabPadding, 0, tabPadding, 0);
      }

      if (v instanceof TextView) {

        TextView tab = (TextView) v;
        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabTypefaceStyle);
        tab.setTextColor(tabTextColor);

        // setAllCaps() is only available from API 14, so the upper case is made manually if we are
        // on a
        // pre-ICS-build
        if (textAllCaps) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            tab.setAllCaps(true);
          } else {
            tab.setText(tab.getText().toString().toUpperCase(locale));
          }
        }
      }
    }
  }
示例#5
0
 private void createLayout(MapActivity activity) {
   FrameLayout fl = (FrameLayout) activity.getMapView().getParent();
   LinearLayout ll = new LinearLayout(activity);
   ll.setOrientation(LinearLayout.HORIZONTAL);
   DisplayMetrics dm = activity.getResources().getDisplayMetrics();
   ll.setPadding(0, 0, (int) (dm.density * 15), (int) (dm.density * 50));
   fl.addView(
       ll,
       new FrameLayout.LayoutParams(
           LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER));
   prev = new ImageButton(activity);
   prev.setContentDescription(activity.getString(R.string.previous_button));
   prev.setBackgroundDrawable(
       activity.getResources().getDrawable(R.drawable.ax_1_navigation_previous_item_light));
   ll.addView(prev);
   info = new ImageButton(activity);
   info.setContentDescription(activity.getString(R.string.info_button));
   info.setPadding((int) (dm.density * 8), 0, 0, 0);
   info.setBackgroundDrawable(
       activity.getResources().getDrawable(R.drawable.ax_2_action_about_light));
   ll.addView(info);
   next = new ImageButton(activity);
   next.setContentDescription(activity.getString(R.string.next_button));
   next.setPadding((int) (dm.density * 8), 0, 0, 0);
   next.setBackgroundDrawable(
       activity.getResources().getDrawable(R.drawable.ax_1_navigation_next_item_light));
   ll.addView(next);
 }
示例#6
0
  private void setFuuboToast(
      Activity activity,
      ViewGroup contentView,
      CharSequence text,
      ToastType toastType,
      long duration,
      final OnToastClickListener toastClickListener) {
    if (activity == null && contentView == null) {
      return;
    }
    mActivity = activity;

    if (contentView != null) {
      mContentView = contentView;
      mToastView.setPadding(
          (int) getResources().getDimension(R.dimen.alifetoast_paddingLeft),
          (int) getResources().getDimension(R.dimen.alifetoast_paddingTop),
          0,
          0);
    } else {
      mContentView = (ViewGroup) mActivity.findViewById(android.R.id.content);
      mToastView.setPadding(
          (int) getResources().getDimension(R.dimen.alifetoast_paddingLeft),
          ACTIONBAR_STATUSBAR_HEIGHT
              + (int) getResources().getDimension(R.dimen.alifetoast_paddingTop),
          0,
          0);
    }
    mToastText.setTextColor(getResources().getColor(R.color.actionbar0));

    mTaskQueue.offer(new ToastTask(mContentView, text, toastType, duration, toastClickListener));

    mToastView.findViewById(R.id.toast_container).setBackgroundResource(R.drawable.toast);
  }
 @Override
 protected void fitSystemWindows(Rect insets) {
   mListView.setPadding(insets.left, insets.top, insets.right, insets.bottom);
   mErrorContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom);
   mProgressContainer.setPadding(insets.left, insets.top, insets.right, insets.bottom);
   mSystemWindowsInsets.set(insets);
   updateRefreshProgressOffset();
 }
  /* (non-Javadoc)
   * @see us.nineworlds.serenity.widgets.SerenityAdapterView.OnItemSelectedListener#onItemSelected(us.nineworlds.serenity.widgets.SerenityAdapterView, android.view.View, int, long)
   */
  @Override
  public void onItemSelected(TwoWayAdapterView<?> parent, View view, int position, long id) {

    if (previous != null) {
      previous.setPadding(0, 0, 0, 0);
    }

    previous = view;

    view.setPadding(5, 5, 5, 5);
  }
  private void changeHeaderViewByState() {
    lastUpdatedTextView.setText(
        context.getString(R.string.refresh_lasttime) + Common.howTimeAgo(context, lastRefreshTime));
    if (isRefreshable) {
      switch (state) {
        case RELEASE_TO_REFRESH:
          arrowImageView.setVisibility(View.VISIBLE);
          progressBar.setVisibility(View.GONE);
          tipsTextView.setVisibility(View.VISIBLE);
          arrowImageView.clearAnimation();
          arrowImageView.startAnimation(animation);
          tipsTextView.setText(context.getString(R.string.refresh_release));
          break;
        case PULL_TO_REFRESH:
          progressBar.setVisibility(View.GONE);
          tipsTextView.setVisibility(View.VISIBLE);
          arrowImageView.clearAnimation();
          arrowImageView.setVisibility(View.VISIBLE);
          // 是由RELEASE_To_REFRESH状态转变来的
          if (isBack) {
            isBack = false;
            arrowImageView.clearAnimation();
            arrowImageView.startAnimation(reverseAnimation);
          }
          // Log.v(TAG, "当前状态,下拉刷新");
          tipsTextView.setText(context.getString(R.string.refresh_pull));
          break;
        case REFRESHING:
          header.setPadding(0, 0, 0, 0);

          progressBar.setVisibility(View.VISIBLE);
          arrowImageView.clearAnimation();
          arrowImageView.setVisibility(View.GONE);
          // tipsTextview.setText(context.getString(R.string.loading));
          tipsTextView.setVisibility(View.GONE);
          lastUpdatedTextView.setVisibility(View.GONE);
          // Log.v(TAG, "当前状态,正在刷新...");
          break;
        case DONE:
          header.setPadding(0, -1 * headerHeight, 0, 0);

          progressBar.setVisibility(View.GONE);
          arrowImageView.clearAnimation();
          arrowImageView.setImageResource(R.drawable.arrow);
          tipsTextView.setText(context.getString(R.string.refresh_pull));
          tipsTextView.setVisibility(View.VISIBLE);
          lastUpdatedTextView.setVisibility(View.VISIBLE);
          // Log.v(TAG, "当前状态,done");
          break;
        default:
          break;
      }
    }
  }
 private void updateTabStyles() {
   for (int i = 0; i < tabCount; i++) {
     View v = tabsContainer.getChildAt(i);
     v.setLayoutParams(defaultTabLayoutParams);
     if (shouldExpand) {
       v.setPadding(0, 0, 0, 0);
       v.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0F));
     } else {
       v.setPadding(tabPadding, 0, tabPadding, 0);
     }
   }
 }
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        startY = (int) ev.getRawY();
        break;
      case MotionEvent.ACTION_MOVE:
        if (startY == -1) { // 确保startY有效
          startY = (int) ev.getRawY();
        }

        if (mCurrrentState == STATE_REFRESHING) { // 正在刷新时不做处理
          break;
        }

        int endY = (int) ev.getRawY();
        int dy = endY - startY; // 移动偏移量

        if (dy > 0 && getFirstVisiblePosition() == 0) { // 只有下拉并且当前是第一个item,才允许下拉刷新
          int padding = dy - mHeaderViewHeight; // 计算padding
          mHeaderView.setPadding(0, padding, 0, 0); // 设置当前padding

          if (padding > 0 && mCurrrentState != STATE_RELEASE_REFRESH) { // 状态改为松开刷新
            mCurrrentState = STATE_RELEASE_REFRESH;
            refreshState();
          } else if (padding < 0 && mCurrrentState != STATE_PULL_REFRESH) { // 改为下拉刷新状态
            mCurrrentState = STATE_PULL_REFRESH;
            refreshState();
          }

          return true;
        }

        break;
      case MotionEvent.ACTION_UP:
        startY = -1; // 重置

        if (mCurrrentState == STATE_RELEASE_REFRESH) {
          mCurrrentState = STATE_REFRESHING; // 正在刷新
          mHeaderView.setPadding(0, 0, 0, 0); // 显示
          refreshState();
        } else if (mCurrrentState == STATE_PULL_REFRESH) {
          mHeaderView.setPadding(0, -mHeaderViewHeight, 0, 0); // 隐藏
        }

        break;

      default:
        break;
    }
    return super.onTouchEvent(ev);
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (position == 0) {
      LayoutInflater infalInflater =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = infalInflater.inflate(R.layout.postbuttons, null);
      ImageButton ib = (ImageButton) convertView.findViewById(R.id.starButton);
      /* changes the buttons if the dark theme is being used */
      if (PreferenceManager.getDefaultSharedPreferences(context)
          .getString("layout_pick", "default")
          .equals("dark")) {
        ((Button) convertView.findViewById(R.id.unreadButton))
            .setCompoundDrawablesWithIntrinsicBounds(
                context.getResources().getDrawable(R.drawable.webnews_unread_dark),
                null,
                null,
                null);
        ((Button) convertView.findViewById(R.id.replyButton))
            .setCompoundDrawablesWithIntrinsicBounds(
                context.getResources().getDrawable(R.drawable.webnews_reply_dark),
                null,
                null,
                null);
        if (super.getItem(getCount()).equals("true")) {
          ib.setImageResource(R.drawable.webnews_star_dark);
        } else {
          ib.setImageResource(R.drawable.webnews_unstar_dark);
        }
      } else {

        if (super.getItem(getCount()).equals("true"))
          ib.setImageResource(R.drawable.webnews_star_light);
      }

      convertView.setPadding(10, 10, 10, 10);
      convertView.findViewById(R.id.replyButton).setTag(getItem(0) + "|" + getItem(5));
      convertView.findViewById(R.id.unreadButton).setTag(getItem(0));
      ib.setTag(getItem(0));
      return convertView;
    }
    LayoutInflater infalInflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = infalInflater.inflate(R.layout.rowlayout, null);
    convertView.setPadding(10, 10, 10, 10);
    TextView tv = ((TextView) convertView.findViewById(R.id.rowTextView));

    tv.setText((String) getItem(position));

    return convertView;
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   LayoutInflater mInflater = (LayoutInflater) ((Activity) context).getLayoutInflater();
   ViewHolder holder = null;
   if (convertView == null) {
     holder = new ViewHolder();
     convertView = mInflater.inflate(R.layout.tv_grid_item, null);
     holder.imageView = (TextView) convertView.findViewById(R.id.videotvbg);
     holder.textView = (TextView) convertView.findViewById(R.id.videotvName);
     // courseBeans[position].textView = tv;
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   holder.imageView.setText(videobeans.get(position).videoDetail);
   if ("".equals(videobeans.get(position).resourceUrl) != true)
     holder.imageView.setBackgroundDrawable(
         Drawable.createFromPath(videobeans.get(position).resourceUrl));
   else holder.imageView.setBackgroundResource(R.drawable.program_loading_bg);
   holder.textView.setText(videobeans.get(position).videoName);
   // convertView.setPadding(0, 15, 0, 15);
   // Log.i("getView", "+++ postion" + selectedPosition);
   convertView.setPadding(15, 5, 15, 5);
   return convertView;
 }
示例#14
0
  @Override
  protected void initViews() {
    super.initViews();

    // 转发时把输入框的大小稍微设置小一些
    mEditText.setMinimumHeight(DeviceUtils.dp2px(this, 80));
    mEditText.setHint(ResFinder.getString("umeng_comm_write_sth"));
    // 隐藏选择图片的图标
    mGridView.setVisibility(View.GONE);

    // 隐藏话题,地理位置、图片和拍照的图标
    findViewById(ResFinder.getId("umeng_community_loc_layout")).setVisibility(View.GONE);
    findViewById(ResFinder.getId("umeng_comm_loc_layout")).setVisibility(View.GONE);
    findViewById(ResFinder.getId("umeng_comm_topic_layout")).setVisibility(View.GONE);
    findViewById(ResFinder.getId("umeng_comm_take_photo_layout")).setVisibility(View.GONE);
    findViewById(ResFinder.getId("umeng_comm_pick_photo_layout")).setVisibility(View.GONE);
    // 设置转发时,图片跟文本layout可见
    findViewById(ResFinder.getId("umeng_comm_forward_layout")).setVisibility(View.VISIBLE);

    //
    mBottomTabLayout = findViewById(ResFinder.getId("umeng_community_post_tab_bar"));
    int paddingRight = getResources().getDisplayMetrics().widthPixels - DeviceUtils.dp2px(this, 80);
    mBottomTabLayout.setPadding(
        mBottomTabLayout.getPaddingLeft(),
        mBottomTabLayout.getPaddingTop(),
        paddingRight,
        mBottomTabLayout.getPaddingBottom());

    // 显示转发文本的TextView
    mFeedText = (TextView) findViewById(ResFinder.getId("umeng_comm_forward_text"));
    mFeedIcon = (ImageView) findViewById(ResFinder.getId("umeng_comm_forward_img"));
    mTopicTipView.setVisibility(View.GONE); // 转发页面不显示提示话题VIew
  }
示例#15
0
  private void animateOffsetToCorrectPosition() {
    mFrom = mCurrentOffsetTop;
    mFromDragPercent = mCurrentDragPercent;

    mAnimateToCorrectPosition.reset();
    mAnimateToCorrectPosition.setDuration(MAX_OFFSET_ANIMATION_DURATION);
    mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(mAnimateToCorrectPosition);

    if (mRefreshing) {
      mBaseRefreshView.start();
      if (mNotify) {
        if (mListener != null) {
          mListener.onRefresh();
        }
      }
    } else {
      mBaseRefreshView.stop();
      animateOffsetToStartPosition();
    }
    mCurrentOffsetTop = mTarget.getTop();
    mTarget.setPadding(
        mTargetPaddingLeft, mTargetPaddingTop, mTargetPaddingRight, mTotalDragDistance);
  }
  private void supportPadding(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    int left = view.getPaddingLeft(),
        right = view.getPaddingRight(),
        top = view.getPaddingTop(),
        bottom = view.getPaddingBottom();
    PercentLayoutInfo.PercentVal percentVal = info.paddingLeftPercent;
    if (percentVal != null) {
      int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
      left = (int) (base * percentVal.percent);
    }
    percentVal = info.paddingRightPercent;
    if (percentVal != null) {
      int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
      right = (int) (base * percentVal.percent);
    }

    percentVal = info.paddingTopPercent;
    if (percentVal != null) {
      int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
      top = (int) (base * percentVal.percent);
    }

    percentVal = info.paddingBottomPercent;
    if (percentVal != null) {
      int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
      bottom = (int) (base * percentVal.percent);
    }
    view.setPadding(left, top, right, bottom);
  }
  private void init() {
    header = LayoutInflater.from(context).inflate(R.layout.list_header, null);
    footer = LayoutInflater.from(context).inflate(R.layout.listfooter, null);

    arrowImageView = (ImageView) header.findViewById(R.id.head_arrowImageView);
    progressBar = (ImageView) header.findViewById(R.id.head_progressBar);
    tipsTextView = (TextView) header.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) header.findViewById(R.id.head_lastUpdatedTextView);

    Common.measureView(header);
    headerHeight = header.getMeasuredHeight();

    addHeaderView(header, null, false);

    addFooterView(footer, null, false);
    footer.setVisibility(View.GONE);
    header.setPadding(0, -1 * headerHeight, 0, 0);

    animation =
        new RotateAnimation(
            0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   // TODO Auto-generated method stub
   ViewHolder holder = null;
   if (convertView == null) {
     convertView = LayoutInflater.from(c).inflate(R.layout.item_layout_gallery, null);
     holder = new ViewHolder();
     holder.firstTitle = (TextView) convertView.findViewById(R.id.first_title);
     holder.secondTitle = (TextView) convertView.findViewById(R.id.second_title);
     holder.content = (TextView) convertView.findViewById(R.id.content);
     holder.score = (TextView) convertView.findViewById(R.id.score);
     holder.image = (ImageView) convertView.findViewById(R.id.image);
     holder.definition = (ImageView) convertView.findViewById(R.id.definition);
     holder.layout = (LinearLayout) convertView.findViewById(R.id.bottom_frame);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   holder.firstTitle.setVisibility(View.GONE);
   holder.layout.setVisibility(View.GONE);
   holder.definition.setVisibility(View.GONE);
   holder.image.setImageResource(data[position]);
   convertView.setPadding(
       UtilTools.getStandardValue(c, 15),
       UtilTools.getStandardValue(c, 10),
       UtilTools.getStandardValue(c, 15),
       UtilTools.getStandardValue(c, 10));
   convertView.setLayoutParams(layoutParam);
   return convertView;
 }
  private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            pager.setCurrentItem(position);
            // XXX INDSAT TIL DR RADIO: “Nulstil” visning, når der tappes på kanalikon i toppen, så
            // man kommer tilbage til NU-visning (belejligt hvis man har scrollet op el. ned i epg
            // liste)
            // if (delegatePageListener != null && delegatePageListener instanceof Kanaler_frag) {
            //  ((Kanaler_frag) delegatePageListener).klikPåFane(position);
            // }
            // Grimt hack, men desværre umuligt at gøre på en anden måde
            if (Kanal_frag.senesteSynligeFragment != null) {
              Kanal_frag.senesteSynligeFragment.rulBlødtTilAktuelUdsendelse();
            }
            // XXX INDSAT TIL DR RADIO s**t
          }
        });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(
        tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
  }
  public void measureChild(View child) {
    final LauncherAppState app = LauncherAppState.getInstance();
    final DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    final int cellWidth = mCellWidth;
    final int cellHeight = mCellHeight;
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    if (!lp.isFullscreen) {
      lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(), mCountX);

      if (child instanceof LauncherAppWidgetHostView) {
        // Widgets have their own padding, so skip
      } else {
        // Otherwise, center the icon
        int cHeight = getCellContentHeight();
        int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f));
        int cellPaddingX = (int) (grid.edgeMarginPx / 2f);
        child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
      }
    } else {
      lp.x = 0;
      lp.y = 0;
      lp.width = getMeasuredWidth();
      lp.height = getMeasuredHeight();
    }
    int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
    int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
    child.measure(childWidthMeasureSpec, childheightMeasureSpec);
  }
示例#21
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = super.onCreateView(inflater, container, savedInstanceState);
   /* if(v != null) {
       LinearLayout ll = (LinearLayout) v;
       ImageView mockToolbar = new ImageView(getActivity());
       //ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(getActivity(),)
       //params.width = ViewGroup.LayoutParams.MATCH_PARENT;
       //params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
       //mockToolbar.setLayoutParams(params);
       if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
           mockToolbar.setElevation((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()));
       mockToolbar.setBackgroundColor(getResources().getColor(R.color.amber));
       ll.addView(mockToolbar, 0);
       ViewGroup.LayoutParams params = ll.getChildAt(0).getLayoutParams();
       params.width = ViewGroup.LayoutParams.MATCH_PARENT;
       params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
       ll.getChildAt(0).setLayoutParams(params);
       //ListView lv = (ListView) v.findViewById(android.R.id.list);
       //lv.setPadding(10, 10, 10, 10);
   }*/
   view.setPadding(
       0,
       (int)
           TypedValue.applyDimension(
               TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics()),
       0,
       0);
   return view;
 }
 @Override
 public void onNothingSelected(TwoWayAdapterView<?> av) {
   if (previous != null) {
     previous.setPadding(0, 0, 0, 0);
     previous.refreshDrawableState();
   }
 }
  private void addMessageToLayout(Message message) {
    TextView user = new TextView(this);
    TextView messageView = new TextView(this);

    user.setTextColor(getResources().getColor(R.color.messageTitle));
    user.setText(
        "("
            + DateFormat.format("hh:mm aa", message.getTimestamp())
            + ") "
            + message.getUsername()
            + ":");
    user.setTextSize(15);
    user.setPadding(5, 15, 5, 0);
    user.setTypeface(Typeface.DEFAULT_BOLD);

    messageView.setText(message.getContent());
    messageView.setTextColor(getResources().getColor(R.color.textColor));
    messageView.setTextSize(15);
    messageView.setPadding(5, 0, 5, 0);

    View line = new View(this);
    line.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1));
    line.setBackgroundColor(getResources().getColor(R.color.messageLine));
    line.setPadding(0, 0, 0, 15);

    messages.addView(user);
    messages.addView(messageView);
    messages.addView(line);
  }
示例#24
0
 /**
  * 设置foot的底部边距
  *
  * @param topPadding
  */
 private void setFootBottomPadding(int bottomPadding) {
   footView.setPadding(
       footView.getPaddingLeft(),
       footView.getPaddingTop(),
       footView.getPaddingRight(),
       bottomPadding);
   footView.invalidate();
 }
示例#25
0
 public static void setBackgroundColorKeepPadding(View view, int color) {
   int bottom = view.getPaddingBottom();
   int top = view.getPaddingTop();
   int right = view.getPaddingRight();
   int left = view.getPaddingLeft();
   view.setBackgroundColor(color);
   view.setPadding(left, top, right, bottom);
 }
示例#26
0
 /**
  * 解决重新设置背景导致padding失效问题
  *
  * @param view 需要重新设置背景的view
  * @param resid 背景资源id
  */
 public static void setBackgroundKeepPadding(View view, int resid) {
   int bottom = view.getPaddingBottom();
   int top = view.getPaddingTop();
   int right = view.getPaddingRight();
   int left = view.getPaddingLeft();
   view.setBackgroundResource(resid);
   view.setPadding(left, top, right, bottom);
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    KLNode node = mNodes.get(position);
    convertView = getConvertView(node, position, convertView, parent);
    convertView.setPadding(node.getLevel() * 30, 3, 3, 3);
    return convertView;
  }
示例#28
0
 public static void setViewPaddingPercent(
     View v, float paddingLeft, float paddingTop, float paddingRight, float paddingBottom) {
   int pLeft = (int) (getWidth() * paddingLeft / 100);
   int pTop = (int) (getHeight() * paddingTop / 100);
   int pRight = (int) (getWidth() * paddingRight / 100);
   int pBottom = (int) (getHeight() * paddingBottom / 100);
   v.setPadding(pLeft, pTop, pRight, pBottom);
 }
 /** @see android.view.View#setPaddingRelative(int, int, int, int) */
 public static void setPaddingRelative(View view, int start, int top, int end, int bottom) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
     view.setPaddingRelative(start, top, end, bottom);
   } else {
     // Before JB MR1, all layouts are left-to-right, so start == left, etc.
     view.setPadding(start, top, end, bottom);
   }
 }
  /*
   * 收起下拉刷新的控件
   */
  public void onRefreshComplete(boolean success) {
    if (isLoadingMore) { // 正在加载更多...
      mFooterView.setPadding(0, -mFooterViewHeight, 0, 0); // 隐藏脚布局
      isLoadingMore = false;
    } else {
      mCurrrentState = STATE_PULL_REFRESH;
      tvTitle.setText("下拉刷新");
      ivArrow.setVisibility(View.VISIBLE);
      pbProgress.setVisibility(View.INVISIBLE);

      mHeaderView.setPadding(0, -mHeaderViewHeight, 0, 0); // 隐藏

      if (success) {
        tvTime.setText("最后刷新时间:" + getCurrentTime());
      }
    }
  }