本文整理汇总了Java中android.widget.ScrollView类的典型用法代码示例。如果您正苦于以下问题:Java ScrollView类的具体用法?Java ScrollView怎么用?Java ScrollView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScrollView类属于android.widget包,在下文中一共展示了ScrollView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollToBottom
import android.widget.ScrollView; //导入依赖的package包/类
public static void scrollToBottom(final ScrollView scroll, final View inner) {
Handler mHandler = new Handler();
mHandler.post(new Runnable() {
public void run() {
if (scroll == null || inner == null) {
return;
}
int offset = inner.getMeasuredHeight() - scroll.getHeight();
if (offset < 0) {
offset = 0;
}
scroll.smoothScrollTo(0, offset);
}
});
}
示例2: canChildPullUp
import android.widget.ScrollView; //导入依赖的package包/类
public boolean canChildPullUp() {
if (child instanceof AbsListView) {
AbsListView absListView = (AbsListView) child;
return canScrollVertically(child, 1)
|| absListView.getLastVisiblePosition() != mTotalItemCount - 1;
} else if (child instanceof WebView) {
WebView webview = (WebView) child;
if (webview instanceof XWebView) {
return !((XWebView) webview).isBottom();
} else {
float left = webview.getContentHeight() * webview.getScale();
int right = webview.getHeight() + webview.getScrollY();
return left != right;
}
} else if (child instanceof ScrollView) {
ScrollView scrollView = (ScrollView) child;
View childView = scrollView.getChildAt(0);
if (childView != null) {
return canScrollVertically(child, 1)
|| scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight();
}
} else {
return canScrollVertically(child, 1);
}
return true;
}
示例3: optionTutorial
import android.widget.ScrollView; //导入依赖的package包/类
private void optionTutorial() {
((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
int userId = Util.getUserId(Process.myUid());
PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString());
Dialog dlgUsage = new Dialog(this);
dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dlgUsage.setTitle(R.string.title_usage_header);
dlgUsage.setContentView(R.layout.usage);
dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
dlgUsage.setCancelable(true);
dlgUsage.show();
}
示例4: getViews
import android.widget.ScrollView; //导入依赖的package包/类
@Override
public void getViews() {
mInflater = LayoutInflater.from(context);
mCustomWebView = (CustomWebView) findViewById(R.id.webview_custom);
back = (ImageView) findViewById(R.id.back);
toleft_iv_right = (ImageView) findViewById(R.id.toleft_iv_right);
recommend_listview = (ListView) findViewById(R.id.recommend_listview);
shareWeixinIV = (ImageView) findViewById(R.id.share_weixin);
shareFriendsIV = (ImageView) findViewById(R.id.share_friends);
shareQqIV = (ImageView) findViewById(R.id.share_qq);
shareWeiboIV = (ImageView) findViewById(R.id.share_weibo);
recommend_layout = (LinearLayout)findViewById(R.id.recommend_layout);
share = (ImageView) findViewById(R.id.share);
mProgressLayout = (ProgressBarView) findViewById(R.id.pbv_loading);
allProgressLayuot = (ProgressBarView) findViewById(R.id.all_pbv_loading);
share_layout = (LinearLayout)findViewById(R.id.share_layout);
info = (ScrollView) findViewById(R.id.info);
}
示例5: initView
import android.widget.ScrollView; //导入依赖的package包/类
private void initView() {
weatherLayout = (ScrollView)findViewById(R.id.weather_layout);
titleCity = (TextView)findViewById(R.id.title_city);
titleUpdateTime = (TextView)findViewById(R.id.title_update_time);
degreeText = (TextView)findViewById(R.id.degree_text);
weatherInfoText = (TextView)findViewById(R.id.weather_info_text);
forecastLayout = (LinearLayout)findViewById(R.id.forecast_layout);
aqiText = (TextView)findViewById(R.id.aqi_text);
pm25Text = (TextView)findViewById(R.id.pm25_text);
comfortText = (TextView)findViewById(R.id.comfort_text);
carWashText = (TextView)findViewById(R.id.car_wash_text);
sportText = (TextView)findViewById(R.id.sport_text);
bingPicImg = (ImageView)findViewById(R.id.bing_pic);
swipeRefresh = (SwipeRefreshLayout)findViewById(R.id.swipe_refresh);
drawerlayout = (DrawerLayout)findViewById(R.id.drawer_layout);
navButton = (Button)findViewById(R.id.nav_button);
}
示例6: onImageUploaded
import android.widget.ScrollView; //导入依赖的package包/类
@Override
public void onImageUploaded(final String tweet) {
// TODO Auto-generated method stub
uiHandler.removeCallbacksAndMessages(null);
uiHandler.post(new Runnable() {
@Override
public void run() {
if (canChangeUI()) {
OneSheeldTextView tweetItem = (OneSheeldTextView) activity
.getLayoutInflater().inflate(
R.layout.tweet_item,
lastTweetTextContainer, false);
tweetItem.setText(tweet);
lastTweetTextContainer.addView(tweetItem);
((ScrollView) lastTweetTextContainer.getParent())
.invalidate();
}
}
});
}
示例7: onBuildContent
import android.widget.ScrollView; //导入依赖的package包/类
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
int padding = QMUIDisplayHelper.dp2px(mContext, 20);
layout.setPadding(padding, padding, padding, padding);
mEditText = new EditText(mContext);
QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
mEditText.setHint("输入框");
LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
mEditText.setLayoutParams(editTextLP);
layout.addView(mEditText);
TextView textView = new TextView(mContext);
textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
"QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
"同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
"不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
layout.addView(textView);
return layout;
}
示例8: initView
import android.widget.ScrollView; //导入依赖的package包/类
private void initView() {
weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
titileCity = (TextView) findViewById(R.id.title_city);
titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
degressText = (TextView) findViewById(R.id.degress_text);
weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
aqiText = (TextView) findViewById(R.id.aqi_text);
pm25Text = (TextView) findViewById(R.id.pm25_text);
comfortText = (TextView) findViewById(R.id.comfort_text);
carWashText = (TextView) findViewById(R.id.car_wash_text);
sportText = (TextView) findViewById(R.id.sport_text);
bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navButton = (Button) findViewById(R.id.nav_button);
}
示例9: onDirectMessageSent
import android.widget.ScrollView; //导入依赖的package包/类
@Override
public void onDirectMessageSent(final String userHandle,
final String msg) {
// TODO Auto-generated method stub
uiHandler.removeCallbacksAndMessages(null);
uiHandler.post(new Runnable() {
@Override
public void run() {
if (canChangeUI()) {
OneSheeldTextView tweetItem = (OneSheeldTextView) activity
.getLayoutInflater().inflate(
R.layout.tweet_item,
lastTweetTextContainer, false);
tweetItem.setText(activity.getString(R.string.twitter_to)+": " + userHandle + ", "+activity.getString(R.string.twitter_message)+": "
+ msg);
lastTweetTextContainer.addView(tweetItem);
((ScrollView) lastTweetTextContainer.getParent())
.invalidate();
}
}
});
}
示例10: wrapScrollableView
import android.widget.ScrollView; //导入依赖的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);
}
示例11: canChildScrollDown
import android.widget.ScrollView; //导入依赖的package包/类
public static boolean canChildScrollDown(View view) {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (view instanceof AbsListView) {
final AbsListView absListView = (AbsListView) view;
return absListView.getChildCount() > 0
&& (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
|| absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
} else if (view instanceof ScrollView) {
ScrollView scrollView = (ScrollView) view;
if (scrollView.getChildCount() == 0) {
return false;
} else {
return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
}
} else {
return false;
}
} else {
return view.canScrollVertically(1);
}
}
示例12: testScrollEvents
import android.widget.ScrollView; //导入依赖的package包/类
public void testScrollEvents() {
ScrollView scrollView = getViewAtPath(0);
dragUp();
waitForBridgeAndUIIdle();
mScrollListenerModule.waitForScrollIdle();
waitForBridgeAndUIIdle();
ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.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.getScrollY()),
yOffsets.get(yOffsets.size() - 1).doubleValue(),
1e-5);
assertTrue("Begin and End Drag should be called", mScrollListenerModule.dragEventsMatch());
}
示例13: onCreate
import android.widget.ScrollView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.view_topic_activity);
Intent intent = getIntent();
String forum_link = intent.getStringExtra("link_to_get");
cr= new CrawlerRunnable();
cr.initiate_url(forum_link);
cr.start();
t = (TextView)findViewById(R.id.text_view2);
t.setOnClickListener(listener);
t.setVisibility(View.INVISIBLE);
sv = (ScrollView)findViewById(R.id.scroll_view3);
ll = (LinearLayout)findViewById(R.id.linear_layout3);
try {
handler.removeCallbacks(time_task);
handler.postDelayed(time_task, 1000);
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: getBitmapByView
import android.widget.ScrollView; //导入依赖的package包/类
public static Bitmap getBitmapByView(ScrollView scrollView) {
int h = 0;
for (int i = 0; i < scrollView.getChildCount(); i++) {
h += scrollView.getChildAt(i).getHeight();
}
Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Config.ARGB_8888);
scrollView.draw(new Canvas(bitmap));
return bitmap;
}
示例15: findFirstScrollerByRootView
import android.widget.ScrollView; //导入依赖的package包/类
public static View findFirstScrollerByRootView(View rootView){
View firstScrollView = null;
if(null != rootView){
allViews = ViewUtil.getAllChildViews(rootView);
for (View view:allViews
) {
if(view instanceof ScrollView){
firstScrollView = view;
break;
}
}
}
return firstScrollView;
}