本文整理匯總了Java中android.widget.HorizontalScrollView類的典型用法代碼示例。如果您正苦於以下問題:Java HorizontalScrollView類的具體用法?Java HorizontalScrollView怎麽用?Java HorizontalScrollView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HorizontalScrollView類屬於android.widget包,在下文中一共展示了HorizontalScrollView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scrollCompat
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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;
}
示例2: setImage
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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;
}
示例3: onBindViewHolder
import android.widget.HorizontalScrollView; //導入依賴的package包/類
@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();
}
});
}
示例4: init
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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();
}
示例5: wrapScrollableView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
/**
* 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);
}
示例6: initImageListView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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);
}
}
示例7: isHorizontalView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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;
}
示例8: getInterfaceComponents
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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();
}
});
}
示例9: CarouselView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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);
}
示例10: center
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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;
}
示例11: initImageListView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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);
}
}
示例12: removeAllLevels
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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--;
}
}
示例13: testScrollEvents
import android.widget.HorizontalScrollView; //導入依賴的package包/類
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);
}
示例14: testScrollToCommand
import android.widget.HorizontalScrollView; //導入依賴的package包/類
/**
* 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());
}
示例15: findScrollView
import android.widget.HorizontalScrollView; //導入依賴的package包/類
/**
* 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;
}