Search in sources :

Example 81 with ScrollView

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();
}
Also used : Window(android.view.Window) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 82 with ScrollView

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;
}
Also used : ScrollView(android.widget.ScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) NestedScrollView(android.support.v4.widget.NestedScrollView) WebView(android.webkit.WebView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 83 with ScrollView

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;
}
Also used : ScrollView(android.widget.ScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) AbsListView(android.widget.AbsListView) SuppressLint(android.annotation.SuppressLint) RecyclerView(android.support.v7.widget.RecyclerView) Method(java.lang.reflect.Method) WebView(android.webkit.WebView) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 84 with ScrollView

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);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 85 with ScrollView

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;
}
Also used : MediaWikiImageView(fr.free.nrw.commons.MediaWikiImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ViewTreeObserver(android.view.ViewTreeObserver) LicenseList(fr.free.nrw.commons.LicenseList)

Aggregations

ScrollView (android.widget.ScrollView)363 View (android.view.View)173 TextView (android.widget.TextView)149 LinearLayout (android.widget.LinearLayout)93 ImageView (android.widget.ImageView)65 ViewGroup (android.view.ViewGroup)53 Button (android.widget.Button)36 EditText (android.widget.EditText)36 ListView (android.widget.ListView)29 RecyclerView (android.support.v7.widget.RecyclerView)25 Intent (android.content.Intent)24 AbsListView (android.widget.AbsListView)24 AdapterView (android.widget.AdapterView)24 GridLayout (android.widget.GridLayout)24 ArrayList (java.util.ArrayList)21 SuppressLint (android.annotation.SuppressLint)20 WebView (android.webkit.WebView)19 FrameLayout (android.widget.FrameLayout)19 Dialog (android.app.Dialog)17 DialogInterface (android.content.DialogInterface)16