Пример #1
0
        @Override
        public void onClick(View view) {
          switch (view.getId()) {
            case R.id.dynamic_addView_btn_add:
              if (mItemViewIndex == 1) { // 在此处获取ItemView的高度
                mItemViewHeight = mDynamicContainer.getMeasuredHeight();
                Log.i(TAG, "mItemViewHeight = " + mItemViewHeight);
              }
              addItemView();
              mDynamicContainerHeight = mDynamicContainer.getMeasuredHeight();
              Log.i(TAG, "mDynamicContainerHeight = " + mDynamicContainerHeight);
              mActivity.setScrollViewScroll(mDynamicContainerHeight);
              break;

            case R.id.dynamic_addView_delete_view:
              view = (View) view.getTag();
              Animation animation =
                  AnimationUtils.loadAnimation(mActivity, R.anim.dynamic_delete_item_view);
              view.startAnimation(animation);
              Message msg = mHandler.obtainMessage();
              msg.what = Constant.HANDLER_DYNAMIC_DELETE_ITEM_VIEW;
              msg.obj = view;
              mHandler.sendMessageDelayed(msg, 600);
              break;

            case R.id.begin_time_layout:
            case R.id.end_time_layout:
              showDateTimeDialog(view);
              break;

            default:
              break;
          }
        }
 @Override
 public void run() {
   int off = mLayout.getMeasuredHeight() - sView.getHeight();
   if (off > 0) {
     sView.scrollTo(0, off); // 改变滚动条的位置
   }
 }
Пример #3
0
  private void init() {
    mHeaderLinearLayout = (LinearLayout) mInflater.inflate(R.layout.player_list_header, null);
    headerArrow = (ImageView) mHeaderLinearLayout.findViewById(R.id.header_arrow);
    headerArrow.setImageBitmap(getOptsBitmap(R.drawable.refresh_list_pull_down));
    headerArrow.setVisibility(View.VISIBLE);
    headerTime = (TextView) mHeaderLinearLayout.findViewById(R.id.list_header_time);
    headerInfo = (TextView) mHeaderLinearLayout.findViewById(R.id.list_header_info);
    headerProgressBar = (ProgressBar) mHeaderLinearLayout.findViewById(R.id.header_progressBar);
    // 添加标题 下拉刷新
    //		addHeaderView(mHeaderLinearLayout);

    mFooterLinearLayout = (LinearLayout) mInflater.inflate(R.layout.player_list_footer, null);
    // addFooterView(mFooterLinearLayout);
    footerLoadMore =
        (TextView) mFooterLinearLayout.findViewById(R.id.refresh_list_footer_load_more);
    footerProgressBar =
        (ProgressBar) mFooterLinearLayout.findViewById(R.id.refresh_list_footer_progressbar);
    mFooterLinearLayout.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if ("点击加载".equals(footerLoadMore.getText())) {
              footerLoadMore.setText("正在加载..");
              footerProgressBar.setVisibility(View.VISIBLE);
              if (mRefreshListener != null) {
                mRefreshListener.more();
              }
            }
          }
        });

    this.setSelection(1);
    this.setOnScrollListener(this);
    measureView(mHeaderLinearLayout); // == mHeaderLinearLayout.measure(0,
    // 0);

    mHeaderHeight = mHeaderLinearLayout.getMeasuredHeight();

    mSimpleDateFormat = new SimpleDateFormat("MM-dd hh:mm");
    headerTime.setText("更新时间为: " + mSimpleDateFormat.format(new Date()));
    mRotationAnimUp =
        AnimatorBuilder.createRotationAnimator(
            0f,
            180f,
            AnimatorBuilder.RELATIVE_TO_SELF,
            0.5f,
            AnimatorBuilder.RELATIVE_TO_SELF,
            0.5f);
    mRotationAnimDown =
        AnimatorBuilder.createRotationAnimator(
            180f,
            0f,
            AnimatorBuilder.RELATIVE_TO_SELF,
            0.5f,
            AnimatorBuilder.RELATIVE_TO_SELF,
            0.5f);
  }
Пример #4
0
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    LogUtils.e("ada", "0  onInterceptTouchEvent");

    final int action = ev.getAction();
    if ((action == MotionEvent.ACTION_MOVE) && (mTouchState != TOUCH_STATE_REST)) {
      return true;
    }
    final float x = ev.getX();
    final float y = ev.getY();
    switch (action) {
      case MotionEvent.ACTION_MOVE:
        if (mCurScreen == 1) {
          LinearLayout view = (LinearLayout) getChildAt(1);
          if (y < view.getMeasuredHeight()) {
            ScrollLayout1 l = (ScrollLayout1) view.getChildAt(0);
            int curscreen = l.getCurScreen();
            curscreen++;
            int deltaX = (int) (mLastMotionX - x);
            if (curscreen == 1) {
              if (deltaX < 0) {
                return true;
              } else {
                return false;
              }
            } else {
              if (curscreen == l.getChildCount()) {
                if (deltaX > 0) {
                  return true;
                } else {
                  return false;
                }
              } else {
                return false;
              }
            }
          }
        }
        LogUtils.e(TAG, "0  onInterceptTouchEvent-ACTION_MOVE");
        final int xDiff = (int) Math.abs(mLastMotionX - x);
        if (xDiff > mTouchSlop) {
          mTouchState = TOUCH_STATE_SCROLLING;
        }
        break;
      case MotionEvent.ACTION_DOWN:
        mLastMotionX = x;
        mLastMotionY = y;
        mTouchState = mScroller.isFinished() ? TOUCH_STATE_REST : TOUCH_STATE_SCROLLING;
        break;
      case MotionEvent.ACTION_CANCEL:
      case MotionEvent.ACTION_UP:
        mTouchState = TOUCH_STATE_REST;
        break;
    }
    return mTouchState != TOUCH_STATE_REST;
  }
Пример #5
0
 private void addTopRefreshView() {
   topRefreshView = new LinearLayout(con);
   topRefreshView.setGravity(Gravity.CENTER);
   topRefreshView.setLayoutParams(
       new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   View v = inflate(con, R.layout.view_pull_to_refresh, null);
   progressBarTop = (ProgressBar) v.findViewById(R.id.progressBar);
   imgArrawTop = (ImageView) v.findViewById(R.id.imgArraw);
   textRefreshTop = (TextView) v.findViewById(R.id.textRefresh);
   textRefreshTimeTop = (TextView) v.findViewById(R.id.textRefreshTime);
   textRefreshTimeTop.setVisibility(View.VISIBLE);
   topRefreshView.addView(v);
   addView(topRefreshView, 0);
   measureView(topRefreshView);
   LayoutParams lp =
       new LayoutParams(LayoutParams.MATCH_PARENT, topRefreshView.getMeasuredHeight());
   lp.topMargin = -topRefreshView.getMeasuredHeight();
   topRefreshView.setLayoutParams(lp);
 }
  private void init(Context context) {
    // 设置滑动效果
    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(100);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(100);
    reverseAnimation.setFillAfter(true);

    inflater = LayoutInflater.from(context);
    headView = (LinearLayout) inflater.inflate(R.layout.pull_to_refresh_head, null);

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    arrowImageView.setMinimumWidth(50);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);

    headContentOriginalTopPadding = headView.getPaddingTop();

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight();
    headContentWidth = headView.getMeasuredWidth();

    headView.setPadding(
        headView.getPaddingLeft(),
        -1 * headContentHeight,
        headView.getPaddingRight(),
        headView.getPaddingBottom());
    headView.invalidate();

    // System.out.println("初始高度�?+headContentHeight);
    // System.out.println("初始TopPad�?+headContentOriginalTopPadding);

    addHeaderView(headView);
    setOnScrollListener(this);
  }
Пример #7
0
  private void init(Context context) {
    setCacheColorHint(context.getResources().getColor(android.R.color.transparent));
    inflater = LayoutInflater.from(context);
    headerView = (LinearLayout) inflater.inflate(R.layout.view_pulltorefresh, null);
    lvHeaderTipsTv = (TextView) headerView.findViewById(R.id.lvHeaderTipsTv);
    lvHeaderLastUpdatedTv = (TextView) headerView.findViewById(R.id.lvHeaderLastUpdatedTv);

    lvHeaderArrowIv = (ImageView) headerView.findViewById(R.id.lvHeaderArrowIv);
    // 设置下拉刷新图标的最小高度和宽度
    lvHeaderArrowIv.setMinimumWidth(70);
    lvHeaderArrowIv.setMinimumHeight(50);

    lvHeaderProgressBar = (ProgressBar) headerView.findViewById(R.id.lvHeaderProgressBar);
    measureView(headerView);
    headerContentHeight = headerView.getMeasuredHeight();
    // 设置内边距,正好距离顶部为一个负的整个布局的高度,正好把头部隐藏
    headerView.setPadding(0, -1 * headerContentHeight, 0, 0);
    // 重绘一下
    headerView.invalidate();
    // 将下拉刷新的布局加入ListView的顶部
    addHeaderView(headerView, null, false);
    // 设置滚动监听事件
    setOnScrollListener(this);

    // 设置旋转动画事件
    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    // 一开始的状态就是下拉刷新完的状态,所以为DONE
    state = DONE;
    // 是否正在刷新
    isRefreshable = false;
  }
  private void init(Context context) {
    setCacheColorHint(context.getResources().getColor(R.color.transparent));
    inflater = LayoutInflater.from(context);

    headView = (LinearLayout) inflater.inflate(R.layout.head, null); // listview拼接headview

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    arrowImageView.setMinimumWidth(70);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight(); // 头部高度
    headContentWidth = headView.getMeasuredWidth(); // 头部宽度

    headView.setPadding(
        0, -1 * headContentHeight, 0, 0); // setPadding(int left, int top, int right, int bottom)
    headView.invalidate(); // Invalidate the whole view

    Log.v("size", "width:" + headContentWidth + " height:" + headContentHeight);

    addHeaderView(headView, null, false); // 添加进headview
    setOnScrollListener(this); // 滚动监听

    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true); // 特效animation设置

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true); // 特效reverseAnimation设置

    state = DONE;
    isRefreshable = false;
  }
Пример #9
0
  private void init(Context context) {
    // TODO Auto-generated method stub
    inflater = LayoutInflater.from(context);

    headView = (LinearLayout) inflater.inflate(R.layout.list_head, null);

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    arrowImageView.setMinimumWidth(70);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);

    headView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    // measureView(this);
    measureView(headView);
    headContentHeight = headView.getMeasuredHeight();
    headContentWidth = headView.getMeasuredWidth();

    this.setPadding(0, -1 * headContentHeight, 0, 0);
    this.invalidate();

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

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    state = DONE;

    isRefreshable = false;
  }
Пример #10
0
  private void init(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    innerLayout = new LinearLayout(context);
    innerLayout.setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    innerLayout.setOrientation(LinearLayout.VERTICAL);

    headView = (LinearLayout) inflater.inflate(R.layout.pull_homeactivity_refreshscrollview, null);

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);
    measureView(headView);

    headContentHeight = headView.getMeasuredHeight();
    headContentWidth = headView.getMeasuredWidth();
    headView.setPadding(0, -1 * headContentHeight, 0, 0);
    headView.invalidate();

    innerLayout.addView(headView);
    addView(innerLayout);

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

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    state = DONE;
    isRefreshable = false;
    canReturn = false;
  }
Пример #11
0
  private void initData() {
    adapter = new ViewPagerAdapter(pageViews);
    pager.setAdapter(adapter);
    pager.setCurrentItem(0);
    pageIndicator.setViewPager(pager); // 加上小圆圈

    int w = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    int h = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    layoutImgs.measure(w, h);
    height = layoutImgs.getMeasuredHeight();
    ViewGroup.LayoutParams layoutParamsChild = layoutImgs.getLayoutParams();
    layoutParamsChild.height = 0;
    layoutImgs.setLayoutParams(layoutParamsChild);
  }
Пример #12
0
  void sectionsMove(MotionEvent motionEvent) {

    // TODO make into global variables
    int barHeight = main_sections_bar.getMeasuredHeight();
    int almostUp = 0; // leaving this in case I want to set an upper limit to the bar

    if (motionEvent.getRawY() > main_sections.getMeasuredHeight()) // Bar down stop
    {
      main_sections.setY(main_sections.getMeasuredHeight() - barHeight);
    } else if (motionEvent.getRawY() <= almostUp && main_sections.getY() <= almostUp) // Bar up stop
    {
      main_sections.setY(almostUp);
    } else // Bar moving
    {
      float newTabY = motionEvent.getRawY() - barHeight;

      if (newTabY <= almostUp) newTabY = almostUp;

      float thresh = .20f;
      if (motionEvent.getRawY() < main_sections.getMeasuredHeight() * main_section_threshold_o) {
        double total = main_sections.getMeasuredHeight() * thresh; // Distance of threshold
        double progr =
            main_sections.getMeasuredHeight() * thresh
                - motionEvent.getRawY(); // Progress into threshold
        double modifier = Math.pow((progr / total), 1.8); // 1.8 arbitrarily choosen
        newTabY -= (progr * (1 - modifier));
        if (newTabY <= almostUp) {
          newTabY = almostUp;
        }
        main_section_threshold = (main_section_threshold_o);
      } else if (motionEvent.getRawY()
          > main_sections.getMeasuredHeight() * (1 - main_section_threshold_o)) {
        double total =
            main_sections.getMeasuredHeight()
                - main_sections.getMeasuredHeight() * (1.0f - thresh); // Distance of threshold
        double progr_1 =
            main_sections.getMeasuredHeight()
                - motionEvent.getRawY(); // Progress Inverse into threshold
        double modifier = Math.pow((progr_1 / total), 1.8); // 1.8 arbitrarily choosen
        newTabY += (progr_1 * (1 - modifier));
        if (newTabY > main_sections.getMeasuredHeight() - barHeight) {
          newTabY = main_sections.getMeasuredHeight() - barHeight;
        }
        main_section_threshold = (1 - main_section_threshold_o);
      }

      main_sections.setY(newTabY);
    }
  }
Пример #13
0
  /** Main Sections Motion Events * */
  private void sectionsUp(MotionEvent motionEvent) {

    // TODO make into global variables
    int barHeight = main_sections_bar.getMeasuredHeight();
    int almostUp = 0; // leaving this in case I want to set an upper limit to the bar

    // TODO add momentum logic
    if (motionEvent.getRawY() < MyHelpers.getUsableHeight(this) * main_section_threshold) {
      moveMainSections(main_sections, almostUp);
      main_section_threshold = main_section_threshold_o;
    } else {
      moveMainSections(main_sections, main_sections.getMeasuredHeight() - barHeight);
      main_section_threshold = (1 - main_section_threshold_o);
    }
  }
Пример #14
0
  /**
   * 添加下拉刷新的HeadView
   *
   * @date 2013-11-11 下午9:48:26
   * @change JohnWatson
   * @version 1.0
   */
  private void addHeadView() {
    mHeadView = (LinearLayout) mInflater.inflate(com.gemptc.activities.R.layout.head, null);

    LinearLayout head_linetest =
        (LinearLayout) mHeadView.findViewById(com.gemptc.activities.R.id.head_linetest);

    mArrowImageView = (ImageView) mHeadView.findViewById(R.id.head_arrowImageView);
    mArrowImageView.setMinimumWidth(70);
    mArrowImageView.setMinimumHeight(50);
    mProgressBar = (ProgressBar) mHeadView.findViewById(R.id.head_progressBar);
    mTipsTextView = (TextView) mHeadView.findViewById(R.id.head_tipsTextView);
    mLastUpdatedTextView = (TextView) mHeadView.findViewById(R.id.head_lastUpdatedTextView);

    measureView(mHeadView);
    mHeadViewHeight = mHeadView.getMeasuredHeight();
    mHeadViewWidth = mHeadView.getMeasuredWidth();

    int x = mHeadView.getMeasuredWidth();
    int x1 = mHeadView.getWidth();
    int y1 = mHeadView.getHeight();
    int y = mHeadView.getMeasuredHeight();

    int x12 = head_linetest.getMeasuredWidth();
    int x11 = head_linetest.getWidth();
    int y11 = head_linetest.getHeight();
    int y12 = head_linetest.getMeasuredHeight();

    mHeadView.setPadding(0, -1 * mHeadViewHeight, 0, 0);
    mHeadView.invalidate();

    Log.v("size", "width:" + mHeadViewWidth + " height:" + mHeadViewHeight);

    addHeaderView(mHeadView, null, false);

    mHeadState = DONE;
  }
Пример #15
0
 private void addFooterRefreshView() {
   footerRefreshView = new LinearLayout(con);
   footerRefreshView.setGravity(Gravity.CENTER);
   footerRefreshView.setLayoutParams(
       new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   View v = inflate(con, R.layout.view_pull_to_refresh, null);
   progressBarBottom = (ProgressBar) v.findViewById(R.id.progressBar);
   imgArrawBottom = (ImageView) v.findViewById(R.id.imgArraw);
   textRefreshBottom = (TextView) v.findViewById(R.id.textRefresh);
   footerRefreshView.addView(v);
   addView(footerRefreshView, getChildCount());
   measureView(footerRefreshView);
   LayoutParams lp =
       new LayoutParams(LayoutParams.MATCH_PARENT, footerRefreshView.getMeasuredHeight());
   footerRefreshView.setLayoutParams(lp);
 }
Пример #16
0
  /**
   * 整个头部控件是否已经完全隐藏
   *
   * @return true表示完全隐藏,false表示没有完全隐藏
   */
  private boolean isWholeHeaderViewCompleteInvisible() {
    if (mCustomHeaderView != null && mIsCustomHeaderViewScrollable) {
      // 0表示x,1表示y
      int[] location = new int[2];
      getLocationOnScreen(location);
      int mOnScreenY = location[1];

      mWholeHeaderView.getLocationOnScreen(location);
      int wholeHeaderViewOnScreenY = location[1];
      if (wholeHeaderViewOnScreenY + mWholeHeaderView.getMeasuredHeight() <= mOnScreenY) {
        return true;
      } else {
        return false;
      }
    }
    return true;
  }
 @Override
 public void setBackgroundLayoutSize(LinearLayout layoutBackground) {
   if (layoutBackground != null) {
     int height, width;
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
       width = layoutBackground.getMeasuredWidth();
       height = layoutBackground.getMeasuredHeight();
     } else {
       width = layoutBackground.getWidth();
       height = layoutBackground.getHeight();
     }
     if (height - (getPadding() * 2) == 0) {
       height = (int) dp2px(DEFAULT_PROGRESS_BAR_HEIGHT);
     }
     setBackgroundWidth(width);
     setBackgroundHeight(height);
   }
 }
Пример #18
0
  @Click(R.id.actionbar_more)
  void moreClicked() {
    mActionbarMore.setSelected(true);
    LinearLayout moreContentView =
        (LinearLayout) mInflater.inflate(R.layout.main_more_content, null);

    moreContentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    final PopupWindow popupWindow = new PopupWindow(this);
    popupWindow.setBackgroundDrawable(
        new ColorDrawable(getResources().getColor(R.color.red_dark_washedout)));
    popupWindow.setContentView(moreContentView);
    popupWindow.showAsDropDown(mActionbarMore);
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setOnDismissListener(
        new OnDismissListener() {
          public void onDismiss() {
            mActionbarMore.setSelected(false);
          }
        });

    Button settingsButton = (Button) moreContentView.findViewById(R.id.main_more_content_settings);
    settingsButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, SettingsActivity.class));
            popupWindow.dismiss();
          }
        });

    Button aboutButton = (Button) moreContentView.findViewById(R.id.main_more_content_about);
    aboutButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, AboutActivity_.class));
            popupWindow.dismiss();
          }
        });

    popupWindow.update(moreContentView.getMeasuredWidth(), moreContentView.getMeasuredHeight());
  }
Пример #19
0
  @SuppressLint("NewApi")
  private void init(Context context) {
    setOverScrollMode(View.OVER_SCROLL_NEVER);
    setOnScrollListener(this);

    headerView =
        (LinearLayout) LayoutInflater.from(context).inflate(R.layout.jingdong_item, null, false);
    tv_pull_to_refresh = (TextView) headerView.findViewById(R.id.tv_pull_to_refresh);
    firstSetpView = (FirstSetpView) headerView.findViewById(R.id.first_step_view);
    secondStepView = (SecondStepView) headerView.findViewById(R.id.second_step_view);
    secondStepView.setBackgroundResource(R.drawable.second_step_animation);
    secondAnimation = (AnimationDrawable) secondStepView.getBackground();
    measureView(headerView);
    addHeaderView(headerView);
    headerViewHeight = headerView.getMeasuredHeight();

    headerView.setPadding(0, -headerViewHeight, 0, 0);

    state = DONE;
    isEnd = true;
    isRefreable = false;
  }
Пример #20
0
  /**
   * 添加下拉刷新的HeadView
   *
   * @date 2013-11-11 下午9:48:26
   * @change JohnWatson
   * @version 1.0
   */
  private void addHeadView() {
    mHeadRootView = (LinearLayout) mInflater.inflate(R.layout.pull_to_refresh_head, null);

    mArrowImageView = (ImageView) mHeadRootView.findViewById(R.id.head_arrowImageView);
    mArrowImageView.setMinimumWidth(70);
    mArrowImageView.setMinimumHeight(50);
    mProgressBar = (ImageView) mHeadRootView.findViewById(R.id.head_progressBar);
    mTipsTextView = (TextView) mHeadRootView.findViewById(R.id.head_tipsTextView);
    mLastUpdatedTextView = (TextView) mHeadRootView.findViewById(R.id.head_lastUpdatedTextView);

    measureView(mHeadRootView);
    mHeadViewHeight = mHeadRootView.getMeasuredHeight();
    mHeadViewWidth = mHeadRootView.getMeasuredWidth();

    mHeadRootView.setPadding(0, -1 * mHeadViewHeight, 0, 0);
    mHeadRootView.invalidate();

    Log.v("size", "width:" + mHeadViewWidth + " height:" + mHeadViewHeight);

    addHeaderView(mHeadRootView, null, false);

    mHeadState = DONE;
    changeHeadViewByState();
  }
Пример #21
0
 private int getMeasureHeight() {
   ll_footer.measure(0, 0);
   return ll_footer.getMeasuredHeight();
 }
Пример #22
0
  public void createControls() {
    // 1. Create view groups and controls
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));
    rightStack = new StackWidgetView(view.getContext());
    leftStack = new StackWidgetView(view.getContext());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);
    // for measurement
    statusBar.addView(backToLocation);
    STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
    statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Rect statusBarPadding = new Rect();
    statusBar.getBackground().getPadding(statusBarPadding);
    // 3. put into frame parent layout controls
    FrameLayout parent = (FrameLayout) view.getParent();
    // status bar hides own top part
    int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom;
    // we want that status bar lays over map stack controls
    topMargin -= topRectPadding.top;

    FrameLayout.LayoutParams flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    rightStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER_HORIZONTAL | Gravity.TOP);
    flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
    lanesControl.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    leftStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = -topRectPadding.top;
    statusBar.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            (int) (78 * scaleCoefficient),
            (int) (78 * scaleCoefficient),
            Gravity.RIGHT | Gravity.BOTTOM);
    flp.rightMargin = (int) (10 * scaleCoefficient);
    flp.bottomMargin = (int) (85 * scaleCoefficient);
    alarmControl.setLayoutParams(flp);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
    parent.addView(alarmControl);
    alarmControl.setVisibility(View.GONE);
    lanesControl.setVisibility(View.GONE);

    // update and create controls
    recreateControls();
  }
 /**
  * Returns how big this panel's view should be. This method should only be called when the view
  * has not been attached to a parent.
  *
  * @throws IllegalStateException
  */
 public Size measure() {
   Preconditions.checkState(mContentView.getParent() == null);
   mContentView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
   return new Size(mContentView.getMeasuredWidth(), mContentView.getMeasuredHeight());
 }
Пример #24
0
  private void init(Context context) {
    inflater = LayoutInflater.from(context);
    headView =
        (LinearLayout) inflater.inflate(R.layout.list_refresh_head, null); // listview拼接headview
    footView = inflater.inflate(R.layout.list_more_view, null);
    footView.setVisibility(View.GONE);

    footView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (onLoadaMoreListener != null) {
              onLoadaMoreListener.onLoadMore();
            }
          }
        });

    arrowImageView = (ImageView) headView.findViewById(R.id.array); // headview中各view
    arrowImageView.setMinimumWidth(50);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.progressBar); // headview中各view
    tipsTextview = (TextView) headView.findViewById(R.id.tips); // headview中各view
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.content); // headview中各view

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight(); // 头部高度
    headContentWidth = headView.getMeasuredWidth(); // 头部宽度

    headView.setPadding(
        0, -1 * headContentHeight, 0, 0); // setPadding(int left, int top, int right, int bottom)
    headView.invalidate(); // Invalidate the whole view

    addHeaderView(headView); // 添加进headview
    addFooterView(footView);

    setOnScrollListener(this); // 滚动监听

    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true); // 特效animation设置

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(250);
    reverseAnimation.setFillAfter(true); // 特效reverseAnimation设置
  }