Пример #1
0
  private void init() {

    totalPages = 2;
    Display display =
        ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    screenWidth = display.getWidth();
    screenHeight = display.getHeight();
    //
    mBookView = new CurlView(mContext, screenWidth, screenHeight);
    // prepare view to take all screenshoot
    LinearLayout ll = new LinearLayout(mContext);
    ll.setOrientation(LinearLayout.VERTICAL);
    LayoutInflater factory = LayoutInflater.from(mContext);
    View view = factory.inflate(R.layout.scrach_page, null);
    ll.addView(view, screenWidth, screenHeight);
    View view2 = factory.inflate(R.layout.scrach_page, null);
    ll.addView(view2, screenWidth, screenHeight);
    // hide scrollview's commponent to have clear bitmap
    scrollView = new ScrollView(mContext);
    scrollView.addView(ll);
    scrollView.setVerticalScrollBarEnabled(false);
    scrollView.setHorizontalScrollBarEnabled(false);
    scrollView.setFadingEdgeLength(0);
    addView(scrollView);
    // add true view and some actions
    View view3 = factory.inflate(R.layout.scrach_page, null);
    addView(view3, screenWidth, screenHeight);
    View view4 = factory.inflate(R.layout.scrach_page, null);
    addView(view4, screenWidth, screenHeight);

    addView(mBookView);
    mBookView.setView(view3, view4);
    // view 1

  }
  public void animateSubjectOut(final SubjectCard materia) {
    final List<View> toBeAnimated = new ArrayList<View>();
    boolean after = false;
    for (SubjectCard mtr : mSubjectCards) {
      if (after) toBeAnimated.add(mtr);
      if (mtr == materia) after = true;
    }
    toBeAnimated.add(mAddButton);
    final int numberToBeAnimated = toBeAnimated.size();

    int maxScroll = mScrollView.getChildAt(0).getHeight() - mScrollView.getHeight(),
        materiaHeight = materia.getHeight();
    final int initScroll = mScrollView.getScrollY(),
        scrollBy =
            ((maxScroll < initScroll + materiaHeight)
                    ? Math.max(maxScroll - materiaHeight, 0)
                    : initScroll)
                - initScroll;
    ValueAnimator listAnimator = ValueAnimator.ofFloat(0, -materiaHeight);
    listAnimator.setInterpolator(new DecelerateInterpolator(3.2f));
    listAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            for (int i = 0; i < numberToBeAnimated; i++)
              ViewHelper.setTranslationY(toBeAnimated.get(i), value);
            ViewHelper.setScrollY(
                mScrollView, (int) (initScroll + scrollBy * animation.getAnimatedFraction()));
          }
        });
    listAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            mSubjectCards.remove(materia);
            mSubjectsLayout.removeView(materia);
            mSqlHelper.remove(materia.getData().getSqlID());
            updateTotal();
            mScrollView.setVerticalScrollBarEnabled(true);
            mScrollView.setOnTouchListener(null);
            for (View mtr : toBeAnimated) ViewHelper.setTranslationY(mtr, 0);
          }
        });
    listAnimator.setDuration(700);
    mScrollView.setVerticalScrollBarEnabled(false);
    mScrollView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        }); // disable user scrolling during the animation

    if (ViewHelper.getTranslationX(materia) == 0) materia.swipeRight(0, 0);
    listAnimator.setStartDelay(500);
    listAnimator.start();
  }
Пример #3
0
 @Override
 public View initView() {
   View inflate = mLayoutInflater.inflate(R.layout.news_detail_content, null);
   ScrollView scrollView = (ScrollView) inflate.findViewById(R.id.scrollView);
   scrollView.smoothScrollTo(0, 0);
   scrollView.setVerticalScrollBarEnabled(false);
   scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER);
   titleContainer = (RelativeLayout) inflate.findViewById(R.id.title_container);
   titleContainer.setBackgroundColor(
       changeBackgroundColor(mSharedPreferences.getInt(Constracts.KEY_THEME, 0)));
   return inflate;
 }
Пример #4
0
  /** 初始化 */
  private void init() {
    DisplayMetrics dm = new DisplayMetrics();
    ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(dm);
    mDensity = dm.density;
    mWidth = dm.widthPixels;

    mFragmentManager = ((FragmentActivity) getContext()).getSupportFragmentManager();

    mContainerScrollView = new NoScrollView(getContext());
    mContainerLinearLayout = new LinearLayout(getContext());

    LayoutParams layoutParams =
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    mContainerScrollView.setLayoutParams(layoutParams);
    mContainerLinearLayout.setLayoutParams(layoutParams);

    mContainerScrollView.addView(mContainerLinearLayout);
    addView(mContainerScrollView);

    mContainerScrollView.setVerticalScrollBarEnabled(false);
    mContainerLinearLayout.setOrientation(LinearLayout.VERTICAL);
  }
    public ActionBarPopupWindowLayout(Context context) {
      super(context);

      if (backgroundDrawable == null) {
        backgroundDrawable = getResources().getDrawable(R.drawable.popup_fixed);
      }

      setPadding(
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8),
          AndroidUtilities.dp(8));
      setWillNotDraw(false);

      try {
        scrollView = new ScrollView(context);
        scrollView.setVerticalScrollBarEnabled(false);
        addView(
            scrollView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
      } catch (Throwable e) {
        FileLog.e("tmessages", e);
      }

      linearLayout = new LinearLayout(context);
      linearLayout.setOrientation(LinearLayout.VERTICAL);
      if (scrollView != null) {
        scrollView.addView(
            linearLayout,
            new ScrollView.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      } else {
        addView(
            linearLayout,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
      }
    }
  @SuppressWarnings("deprecation")
  public VerticalScrollAutoSelector(Context context, AttributeSet attrs) {
    super(context, attrs);

    mContentScrollView = new ScrollView(context);
    LinearLayout.LayoutParams linearLP =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    mContentScrollView.setLayoutParams(linearLP);
    mContentScrollView.setVerticalScrollBarEnabled(false);
    addView(mContentScrollView);

    mStartBlankView = new TextView(context);
    mEndBlankView = new TextView(context);
    mItemLayoutParams =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mItemsContainer = new LinearLayout(context);
    mItemsContainer.setOrientation(LinearLayout.VERTICAL);
    mItemsContainer.setGravity(Gravity.CENTER);
    mItemsContainer.setLayoutParams(mItemLayoutParams);
    mContentScrollView.addView(mItemsContainer);
    mContentScrollView.setOnTouchListener(new ScrollViewOnTouchListener());
  }