Java 类android.widget.HorizontalScrollView 实例源码

项目:SmoothRefreshLayout    文件:HorizontalScrollCompat.java   
public static boolean scrollCompat(View view, float deltaY) {
    if (view != null) {
        if ((view instanceof WebView)
                || (view instanceof HorizontalScrollView)) {
            view.scrollBy((int) deltaY, 0);
        } else {
            try {
                if (view instanceof RecyclerView) {
                    view.scrollBy((int) deltaY, 0);
                    return true;
                }
            } catch (NoClassDefFoundError e) {
                //ignore exception
            }
        }
    }
    return false;
}
项目:gravity-view    文件:GravityView.java   
public GravityView setImage(ImageView image, int drawable) {
    image_view = image;
    Bitmap bmp = resizeBitmap(Common.getDeviceHeight(mContext), drawable);
    image_view.setLayoutParams(new HorizontalScrollView.LayoutParams(bmp.getWidth(), bmp.getHeight()));
    image_view.setImageBitmap(bmp);
    mMaxScroll = bmp.getWidth();
    if (image.getParent() instanceof HorizontalScrollView) {
            ((HorizontalScrollView) image.getParent()).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {
                    return true;
                }
            });
    }
    return gravityView;
}
项目:gravity-view    文件:GravityView.java   
public GravityView setImage(ImageView image, Bitmap bitmap) {
    image_view = image;
    Bitmap bmp = resizeBitmap(Common.getDeviceHeight(mContext), bitmap);
    image_view.setLayoutParams(new HorizontalScrollView.LayoutParams(bmp.getWidth(), bmp.getHeight()));
    image_view.setImageBitmap(bmp);
    mMaxScroll = bmp.getWidth();
    if (image.getParent() instanceof HorizontalScrollView) {
        ((HorizontalScrollView) image.getParent()).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return true;
            }
        });
    }
    return gravityView;
}
项目:GitHub    文件:LineActivity2.java   
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
    if(holder.itemView.getScrollX()!=0){
        ((HorizontalScrollView)holder.itemView).fullScroll(View.FOCUS_UP);//如果item的HorizontalScrollView没在初始位置,则滚动回顶部
    }
    holder.ll.setMinimumWidth(screenwidth);//设置LinearLayout宽度为屏幕宽度
    holder.tv.setText("图"+position);
    Picasso.with(LineActivity2.this).load(meizis.get(position).getUrl()).into(holder.iv);

    holder.ll.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SnackbarUtil.ShortSnackbar(coordinatorLayout,"点击第"+position+"个",SnackbarUtil.Info).show();
        }
    });
}
项目:GitHub    文件:CommonNavigator.java   
private void init() {
    removeAllViews();

    View root;
    if (mAdjustMode) {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
    } else {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
    }

    mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view);   // mAdjustMode为true时,mScrollView为null

    mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);
    mTitleContainer.setPadding(mLeftPadding, 0, mRightPadding, 0);

    mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
    if (mIndicatorOnTop) {
        mIndicatorContainer.getParent().bringChildToFront(mIndicatorContainer);
    }

    initTitlesAndIndicator();
}
项目:android_ui    文件:ScrollableWrapper.java   
/**
 * Wraps the given <var>scrollableView</var> into scrollable wrapper implementation that best
 * suits to the type of the given view.
 *
 * @param scrollableView The scrollable view to be wrapped into scrollable wrapper.
 * @return New scrollable wrapper instance. See description of this class for supported wrappers.
 */
@SuppressWarnings("unchecked")
public static <V extends View> ScrollableWrapper<V> wrapScrollableView(@NonNull V scrollableView) {
    if (scrollableView instanceof AbsListView) {
        return new AbsListViewWrapper((AbsListView) scrollableView);
    } else if (scrollableView instanceof RecyclerView) {
        return new RecyclerViewWrapper((RecyclerView) scrollableView);
    } else if (scrollableView instanceof ScrollView) {
        return new ScrollViewWrapper((ScrollView) scrollableView);
    } else if (scrollableView instanceof HorizontalScrollView) {
        return new HorizontalScrollViewWrapper((HorizontalScrollView) scrollableView);
    } else if (scrollableView instanceof ViewPager) {
        return new ViewPagerWrapper((ViewPager) scrollableView);
    } else if (scrollableView instanceof WebView) {
        return new WebViewWrapper((WebView) scrollableView);
    }
    return new ViewWrapper(scrollableView);
}
项目:ywApplication    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}
项目:SmoothRefreshLayout    文件:BoundaryUtil.java   
private static boolean isHorizontalView(View view) {
    if (view instanceof ViewPager || view instanceof HorizontalScrollView
            || view instanceof WebView) {
        return true;
    }
    try {
        if (view instanceof RecyclerView) {
            RecyclerView recyclerView = (RecyclerView) view;
            RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
            if (manager != null) {
                if (manager instanceof LinearLayoutManager) {
                    LinearLayoutManager linearManager = ((LinearLayoutManager) manager);
                    if (linearManager.getOrientation() == LinearLayoutManager.HORIZONTAL)
                        return true;
                } else if (manager instanceof StaggeredGridLayoutManager) {
                    StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
                    if (gridLayoutManager.getOrientation() == StaggeredGridLayoutManager.HORIZONTAL)
                        return true;
                }
            }
        }
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
    }
    return false;
}
项目:topnews    文件:CommonNavigator.java   
private void init() {
    removeAllViews();

    View root;
    if (mAdjustMode) {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
    } else {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
    }

    mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view);   // mAdjustMode为true时,mScrollView为null

    mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);
    mTitleContainer.setPadding(mLeftPadding, 0, mRightPadding, 0);

    mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
    if (mIndicatorOnTop) {
        mIndicatorContainer.getParent().bringChildToFront(mIndicatorContainer);
    }

    initTitlesAndIndicator();
}
项目:home-assistant-android    文件:Surface.java   
private void getInterfaceComponents() {

        //Controlsurface setup
        scrollView = (HorizontalScrollView) findViewById(R.id.scrollView);
        scrollViewItems = (LinearLayout) findViewById(R.id.scrollViewItems);
        shortcutButtons = (LinearLayout) findViewById(R.id.shortcutButtons);
        scrollView.smoothScrollTo(0,0);
        scrollView.setEnabled(false);

        settingsView = (LinearLayout) findViewById(R.id.settingsView);
        settingsHassIp = (EditText) findViewById(R.id.hassIpAddress);
        settingsHassPort = (EditText) findViewById(R.id.hassPort);
        settingsHassGroup = (EditText) findViewById(R.id.hassGroup);
        settingsHassPassword = (EditText) findViewById(R.id.hassPassword);
        setupError = (TextView) findViewById(R.id.setupError);

        settingsSubmitButton = (Button) findViewById(R.id.settingsSubmitButton);
        settingsSubmitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                storeSettings();
            }
        });
    }
项目:carousel-picker-android    文件:CarouselView.java   
public CarouselView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);

    inflate(getContext(), R.layout.main, this);

    indicatorsMap = new HashMap<>();

    pickerScroll = (HorizontalScrollView) findViewById(R.id.picker_horizontal_scroll);
    pickerLayout = (LinearLayout) findViewById(R.id.picker_linear_layout);

    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CarouselPicker, 0, 0);
    customIndicator = typedArray.getResourceId(R.styleable.CarouselPicker_customIndicator,0);
    displayIndicator = typedArray.getBoolean(R.styleable.CarouselPicker_displayIndicator,false);
    customIndicatorColor = typedArray.getResourceId(R.styleable.CarouselPicker_customIndicatorColor,0);
    customIndicatorSize = typedArray.getResourceId(R.styleable.CarouselPicker_customIndicatorSize,0);
    customDescriptionColor = typedArray.getResourceId(R.styleable.CarouselPicker_customDescriptionColor,0);
}
项目:gravity-view    文件:GravityView.java   
public GravityView center() {
    image_view.post(new Runnable() {
        @Override
        public void run() {
            if (mImageWidth > 0) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    ((HorizontalScrollView) image_view.getParent()).setScrollX(mImageWidth / 4);
                else
                    ((HorizontalScrollView) image_view.getParent()).setX(mImageWidth / 4);
            } else {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    ((HorizontalScrollView) image_view.getParent()).setScrollX(((HorizontalScrollView) image_view.getParent()).getWidth() / 2);
                else
                    ((HorizontalScrollView) image_view.getParent()).setX(((HorizontalScrollView) image_view.getParent()).getWidth() / 2);
            }
        }
    });
    return gravityView;
}
项目:boohee_v5.6    文件:EditPage.java   
private void initImageListView() {
    HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    if (!initImageList(new ImageListResultsCallback() {
        public void onFinish(ArrayList<ImageInfo> results) {
            if (results != null) {
                LinearLayout layout = (LinearLayout) EditPage.this.findViewByResName("imagesLinearLayout");
                Iterator it = results.iterator();
                while (it.hasNext()) {
                    ImageInfo imageInfo = (ImageInfo) it.next();
                    if (imageInfo.bitmap != null) {
                        layout.addView(EditPage.this.makeImageItemView(imageInfo));
                    }
                }
            }
        }
    })) {
        hScrollView.setVisibility(8);
    }
}
项目:richeditor    文件:LuBottomMenu.java   
private void removeAllLevels(int num) {
    if (num >= mDisplayRowNum || num < 1)
        return;

    int b = mDisplayRowNum - num;
    for (int i = mDisplayRowNum - 1; i >= b; i--) {
        if (mDisplayMenus.get(i).getChildAt(0) instanceof HorizontalScrollView) {
            View v = ((HorizontalScrollView) mDisplayMenus.get(i).getChildAt(0)).getChildAt(0);
            if (v != null && v instanceof LinearLayout)
                ((LinearLayout) v).removeAllViews();
        }
        mDisplayMenus.get(i).removeAllViews();
        mDisplayMenus.remove(i);
        removeView(getChildAt(i));
        getBottomMenuItem(mPathRecord.peek()).setSelected(false);
        mPathRecord.pop();
        mDisplayRowNum--;
    }
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:RNLearn_Project1    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:Multi-SwipeBackLayout    文件:SwipeBackLayout.java   
/**
 * Find out the scrollable child view
 * 这里添加了常用的一些可滑动类,特殊类需要添加
 *
 * @param target targetView
 */
private void findScrollView(ViewGroup target) {
    final int count = target.getChildCount();
    if (count > 0) {
        for (int i = 0; i < count; i++) {
            final View child = target.getChildAt(i);
            if (child instanceof AbsListView
                    || isInstanceOfClass(child, ScrollView.class.getName())
                    || isInstanceOfClass(child, NestedScrollView.class.getName())
                    || isInstanceOfClass(child, RecyclerView.class.getName())
                    || child instanceof HorizontalScrollView
                    || child instanceof ViewPager
                    || child instanceof WebView) {
                mScrollChild = child;
                break;
            } else if (child instanceof ViewGroup) {
                findScrollView((ViewGroup) child);
            }
        }
    }
    if (mScrollChild == null) mScrollChild = target;
}
项目:ReactNativeSignatureExample    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:ReactNativeSignatureExample    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:MyTravelingDiary    文件:ScrollGalleryView.java   
public ScrollGalleryView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    images = new ArrayList<>();

    setOrientation(VERTICAL);
    displayProps = getDisplaySize();
    LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.scroll_gallery_view, this, true);

    horizontalScrollView = (HorizontalScrollView)findViewById(R.id.thumbnails_scroll_view);

    thumbnailsContainer = (LinearLayout)findViewById(R.id.thumbnails_container);
    thumbnailsContainer.setPadding(displayProps.x / 2, 0,
            displayProps.x / 2, 0);
}
项目:NavigationBar    文件:NavitationScrollLayout.java   
public NavitationScrollLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    margleft = dip2px(context, 0);
    titleLayout = new LinearLayout(context);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
    titleLayout.setLayoutParams(layoutParams);
    titleLayout.setOrientation(LinearLayout.HORIZONTAL);
    titleLayout.setGravity(Gravity.CENTER_VERTICAL);

    LayoutParams layoutParams2 = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
    horizontalScrollView = new HorizontalScrollView(context);
    horizontalScrollView.addView(titleLayout, layoutParams2);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    addView(horizontalScrollView);
}
项目:react-native-ibeacon-android    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:react-native-ibeacon-android    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:Myshop    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}
项目:Li-MVPArms    文件:CommonNavigator.java   
private void init() {
    removeAllViews();

    View root;
    if (mAdjustMode) {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
    } else {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
    }

    mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view);   // mAdjustMode为true时,mScrollView为null

    mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);
    mTitleContainer.setPadding(mLeftPadding, 0, mRightPadding, 0);

    mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
    if (mIndicatorOnTop) {
        mIndicatorContainer.getParent().bringChildToFront(mIndicatorContainer);
    }

    initTitlesAndIndicator();
}
项目:react-native-box-loaders    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:react-native-box-loaders    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:InternetShopping    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}
项目:Ironman    文件:ReactHorizontalScrollViewTestCase.java   
public void testScrollEvents() {
  HorizontalScrollView scrollView = getViewAtPath(0);

  dragLeft();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> xOffsets = mScrollListenerModule.getXOffsets();
  assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
      xOffsets.get(xOffsets.size() - 1).doubleValue(),
      1e-5);
}
项目:Ironman    文件:ReactHorizontalScrollViewTestCase.java   
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
项目:CameraSDK-master    文件:PhotoPickActivity.java   
private void initViews(){
    showLeftIcon();
    mCategoryText = (TextView)findViewById(R.id.camerasdk_actionbar_title);
    Drawable drawable= getResources().getDrawable(R.drawable.message_popover_arrow);  
    drawable.setBounds(10, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());  
    mCategoryText.setCompoundDrawables(null,null,drawable,null);  

    mTimeLineText = (TextView)findViewById(R.id.timeline_area);
    button_complate = (TextView)findViewById(R.id.button_complate);
    mGridView=(GridView)findViewById(R.id.gv_list);
    camera_footer = (RelativeLayout)findViewById(R.id.camera_footer);
    selectedImageLayout = (LinearLayout) findViewById(R.id.selected_image_layout);
    scrollview = (HorizontalScrollView) findViewById(R.id.scrollview);

    button_complate.setText("完成(0/"+mCameraSdkParameterInfo.getMax_image()+")");

    mImageAdapter = new ImageGridAdapter(mContext, mCameraSdkParameterInfo.isShow_camera(),mCameraSdkParameterInfo.isSingle_mode());
    mGridView.setAdapter(mImageAdapter);
    mFolderAdapter = new FolderAdapter(mContext);

    if(mCameraSdkParameterInfo.isSingle_mode()){
        camera_footer.setVisibility(View.GONE);
    }
}
项目:BigApp_Discuz_Android    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}
项目:csdn-master    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}
项目:BaseLibrary    文件:CommonNavigator.java   
private void init() {
    removeAllViews();

    View root;
    if (mAdjustMode) {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
    } else {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
    }

    mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view);   // mAdjustMode为true时,mScrollView为null

    mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);
    mTitleContainer.setPadding(mLeftPadding, 0, mRightPadding, 0);

    mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
    if (mIndicatorOnTop) {
        mIndicatorContainer.getParent().bringChildToFront(mIndicatorContainer);
    }

    initTitlesAndIndicator();
}
项目:MifareClassicTool    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setIcon(R.mipmap.ic_launcher);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    sConsoleWnd = getWindow();
    sConsoleOutput = (TextView)findViewById(R.id.consoleOutput);
    sConsoleScrollHorizontal = (HorizontalScrollView)findViewById(R.id.consoleScrollHorizontal);
    sConsoleScrollVertical = (NestedScrollView)findViewById(R.id.consoleScrollVertical);
    mConsoleTextColorDefault = ContextCompat.getColor(this, R.color.colorConsoleTextDefault);
    mConsoleTextColorWarn = ContextCompat.getColor(this, R.color.colorConsoleTextWarning);
    mConsoleTextColorNotice = ContextCompat.getColor(this, R.color.colorConsoleTextNotice);

}
项目:PixaToon    文件:FilterSelectorFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_filterselector, container, false);
    mFilterMap = new HashMap<>();
    initFilterMap();

    for(int filterBtnId : mFilterMap.keySet()) {
        View filterSelectBtn = view.findViewById(filterBtnId);
        filterSelectBtn.setOnClickListener(this);
        if(((MainActivity)getActivity()).getOrientation() == Configuration.ORIENTATION_LANDSCAPE)
            filterSelectBtn.setRotation(90);
    }

    mScrollBar = (HorizontalScrollView)view.findViewById(R.id.scrollBar);
    return view;
}
项目:WhiteRead    文件:CommonNavigator.java   
private void init() {
    removeAllViews();

    View root;
    if (mAdjustMode) {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout_no_scroll, this);
    } else {
        root = LayoutInflater.from(getContext()).inflate(R.layout.pager_navigator_layout, this);
    }

    mScrollView = (HorizontalScrollView) root.findViewById(R.id.scroll_view);   // mAdjustMode为true时,mScrollView为null
    if (!mAdjustMode) {
        mScrollView.getChildAt(0).setPadding(mLeftPadding, 0, mRightPadding, 0);    // TODO padding的效果尚未达到预期
    }

    mIndicatorContainer = (LinearLayout) root.findViewById(R.id.indicator_container);
    mTitleContainer = (LinearLayout) root.findViewById(R.id.title_container);

    initTitlesAndIndicator();
}
项目:BigApp_WordPress_Android    文件:EditPage.java   
private void initImageListView() {
    final HorizontalScrollView hScrollView = (HorizontalScrollView) findViewByResName("hScrollView");
    ImageListResultsCallback callback = new ImageListResultsCallback() {

        @Override
        public void onFinish(ArrayList<ImageInfo> results) {
            if(results == null)
                return;
            LinearLayout layout = (LinearLayout) findViewByResName("imagesLinearLayout");
            for(ImageInfo imageInfo : results) {
                if(imageInfo.bitmap == null)
                    continue;
                layout.addView(makeImageItemView(imageInfo));
            }
        }
    };
    if(!initImageList(callback)) {
        hScrollView.setVisibility(View.GONE);
    }

}