use of android.widget.ScrollView in project AndroidChromium by JackyAndroid.
the class WebsiteSettingsPopup method showDialog.
/**
* Displays the WebsiteSettingsPopup.
*/
private void showDialog() {
if (!DeviceFormFactor.isTablet(mContext)) {
// On smaller screens, make the dialog fill the width of the screen.
ScrollView scrollView = new ScrollView(mContext);
scrollView.addView(mContainer);
mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
// This must be called after addContentView, or it won't fully fill to the edge.
Window window = mDialog.getWindow();
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
} else {
// On larger screens, make the dialog centered in the screen and have a maximum width.
ScrollView scrollView = new ScrollView(mContext) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int maxDialogWidthInPx = (int) (MAX_TABLET_DIALOG_WIDTH_DP * mContext.getResources().getDisplayMetrics().density);
if (MeasureSpec.getSize(widthMeasureSpec) > maxDialogWidthInPx) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxDialogWidthInPx, MeasureSpec.EXACTLY);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
scrollView.addView(mContainer);
mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
}
mDialog.show();
}
use of android.widget.ScrollView in project SmoothRefreshLayout by dkzwm.
the class HorizontalBoundaryUtil method isVerticalView.
private static boolean isVerticalView(View view) {
if (view instanceof AbsListView || view instanceof ScrollView || view instanceof NestedScrollView || 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.VERTICAL)
return true;
} else if (manager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
if (gridLayoutManager.getOrientation() == StaggeredGridLayoutManager.VERTICAL)
return true;
}
}
}
} catch (NoClassDefFoundError e) {
e.printStackTrace();
}
return false;
}
use of android.widget.ScrollView in project SmoothRefreshLayout by dkzwm.
the class ScrollCompat method scrollCompat.
public static boolean scrollCompat(View view, float deltaY) {
if (view != null) {
if (view instanceof AbsListView) {
final AbsListView listView = (AbsListView) view;
if (Build.VERSION.SDK_INT >= 19) {
listView.scrollListBy((int) deltaY);
return true;
} else {
try {
@SuppressLint("PrivateApi") Method method = AbsListView.class.getDeclaredMethod("trackMotionScroll", int.class, int.class);
if (method != null) {
method.setAccessible(true);
method.invoke(listView, -(int) deltaY, -(int) deltaY);
}
} catch (Exception e) {
return false;
}
}
return true;
} else if ((view instanceof WebView) || (view instanceof ScrollView) || (view instanceof NestedScrollView)) {
view.scrollBy(0, (int) deltaY);
} else {
try {
if (view instanceof RecyclerView) {
view.scrollBy(0, (int) deltaY);
return true;
}
} catch (NoClassDefFoundError e) {
// ignore exception
}
}
}
return false;
}
use of android.widget.ScrollView in project android_frameworks_base by crdroidandroid.
the class MicroAlertController method setupContent.
@Override
protected void setupContent(ViewGroup contentPanel) {
// Special case for small screen - the scroll view is higher in hierarchy
mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);
// Special case for users that only want to display a String
mMessageView = (TextView) contentPanel.findViewById(R.id.message);
if (mMessageView == null) {
return;
}
if (mMessage != null) {
mMessageView.setText(mMessage);
} else {
// no message, remove associated views
mMessageView.setVisibility(View.GONE);
contentPanel.removeView(mMessageView);
if (mListView != null) {
// has ListView, swap scrollView with ListView
// move topPanel into top of scrollParent
View topPanel = mScrollView.findViewById(R.id.topPanel);
((ViewGroup) topPanel.getParent()).removeView(topPanel);
FrameLayout.LayoutParams topParams = new FrameLayout.LayoutParams(topPanel.getLayoutParams());
topParams.gravity = Gravity.TOP;
topPanel.setLayoutParams(topParams);
// move buttonPanel into bottom of scrollParent
View buttonPanel = mScrollView.findViewById(R.id.buttonPanel);
((ViewGroup) buttonPanel.getParent()).removeView(buttonPanel);
FrameLayout.LayoutParams buttonParams = new FrameLayout.LayoutParams(buttonPanel.getLayoutParams());
buttonParams.gravity = Gravity.BOTTOM;
buttonPanel.setLayoutParams(buttonParams);
// remove scrollview
final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
final int childIndex = scrollParent.indexOfChild(mScrollView);
scrollParent.removeViewAt(childIndex);
// add list view
scrollParent.addView(mListView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// add top and button panel
scrollParent.addView(topPanel);
scrollParent.addView(buttonPanel);
} else {
// no content, just hide everything
contentPanel.setVisibility(View.GONE);
}
}
}
use of android.widget.ScrollView in project apps-android-commons by commons-app.
the class MediaDetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
detailProvider = (MediaDetailPagerFragment.MediaDetailProvider) getActivity();
if (savedInstanceState != null) {
editable = savedInstanceState.getBoolean("editable");
index = savedInstanceState.getInt("index");
initialListTop = savedInstanceState.getInt("listTop");
} else {
editable = getArguments().getBoolean("editable");
index = getArguments().getInt("index");
initialListTop = 0;
}
categoryNames = new ArrayList<>();
categoryNames.add(getString(R.string.detail_panel_cats_loading));
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);
image = (MediaWikiImageView) view.findViewById(R.id.mediaDetailImage);
scrollView = (ScrollView) view.findViewById(R.id.mediaDetailScrollView);
// Detail consists of a list view with main pane in header view, plus category list.
spacer = (MediaDetailSpacer) view.findViewById(R.id.mediaDetailSpacer);
title = (TextView) view.findViewById(R.id.mediaDetailTitle);
desc = (TextView) view.findViewById(R.id.mediaDetailDesc);
license = (TextView) view.findViewById(R.id.mediaDetailLicense);
coordinates = (TextView) view.findViewById(R.id.mediaDetailCoordinates);
uploadedDate = (TextView) view.findViewById(R.id.mediaDetailuploadeddate);
categoryContainer = (LinearLayout) view.findViewById(R.id.mediaDetailCategoryContainer);
licenseList = new LicenseList(getActivity());
// Progressively darken the image in the background when we scroll detail pane up
scrollListener = new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
updateTheDarkness();
}
};
view.getViewTreeObserver().addOnScrollChangedListener(scrollListener);
// Layout layoutListener to size the spacer item relative to the available space.
// There may be a .... better way to do this.
layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
private int currentHeight = -1;
@Override
public void onGlobalLayout() {
int viewHeight = view.getHeight();
//int textHeight = title.getLineHeight();
int paddingDp = 112;
float paddingPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, paddingDp, getResources().getDisplayMetrics());
int newHeight = viewHeight - Math.round(paddingPx);
if (newHeight != currentHeight) {
currentHeight = newHeight;
ViewGroup.LayoutParams params = spacer.getLayoutParams();
params.height = newHeight;
spacer.setLayoutParams(params);
scrollView.scrollTo(0, initialListTop);
}
}
};
view.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener);
return view;
}
Aggregations