android.widget.ScrollView Java Examples

The following examples show how to use android.widget.ScrollView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SketchFile.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
protected void updateEditor(EditorActivity context) {
	final CodeEditText code = fragment.getCodeEditText();
	final HorizontalScrollView scrollerX = fragment.getCodeScrollerX();
	final ScrollView scrollerY = fragment.getCodeScroller();
	
	//Update the code area text
	code.setNoUndoText(getText());
	//Update the code area selection
	code.setSelection(getSelectionStart(), getSelectionEnd());
	
	code.post(code::updateBracketMatch);
	
	scrollerX.post(() -> scrollerX.scrollTo(getScrollX(), 0));
	
	scrollerY.post(() -> scrollerY.scrollTo(0, getScrollY()));
	
	context.supportInvalidateOptionsMenu();
}
 
Example #2
Source File: CardStreamLinearLayout.java    From sensors-samples with Apache License 2.0 6 votes vote down vote up
private void scrollToCard(String tag) {


        final int count = getChildCount();
        for (int index = 0; index < count; ++index) {
            View child = getChildAt(index);

            if (tag.equals(child.getTag())) {

                ViewParent parent = getParent();
                if( parent != null && parent instanceof ScrollView ){
                    ((ScrollView)parent).smoothScrollTo(
                            0, child.getTop() - getPaddingTop() - child.getPaddingTop());
                }
                return;
            }
        }
    }
 
Example #3
Source File: BottomDialog.java    From BottomDialog with MIT License 6 votes vote down vote up
public CustomDialog(Context context) {
    super(context);
    items = new ArrayList<>();
    icon = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_32_dp);
    padding = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_8_dp);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    container = new LinearLayout(getContext());
    container.setLayoutParams(params);
    container.setBackgroundColor(Color.WHITE);
    container.setOrientation(LinearLayout.VERTICAL);
    container.setPadding(0, padding, 0, padding);
    ScrollView scrollView = new ScrollView(getContext());
    scrollView.addView(container);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(scrollView, params);
    setCancelable(true);
    setCanceledOnTouchOutside(true);
    getWindow().setGravity(Gravity.BOTTOM);
    getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
}
 
Example #4
Source File: IosAlertDialogHolder.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
@Override
protected void findViews() {
    tvTitle = (TextView) rootView.findViewById(R.id.tv_title);
    tvMsg = (TextView) rootView.findViewById(R.id.tv_msg);
    et1 = (EditText) rootView.findViewById(R.id.et_1);
    et2 = (EditText) rootView.findViewById(R.id.et_2);
    line = (View) rootView.findViewById(R.id.line);
    btn1 = (Button) rootView.findViewById(R.id.btn_1);
    lineBtn2 = (View) rootView.findViewById(R.id.line_btn2);
    btn2 = (Button) rootView.findViewById(R.id.btn_2);
    lineBtn3 = (View) rootView.findViewById(R.id.line_btn3);
    btn3 = (Button) rootView.findViewById(R.id.btn_3);
    llContainerHorizontal = (LinearLayout) rootView.findViewById(R.id.ll_container_horizontal);
    btn1Vertical = (Button) rootView.findViewById(R.id.btn_1_vertical);
    lineBtn2Vertical = (View) rootView.findViewById(R.id.line_btn2_vertical);
    btn2Vertical = (Button) rootView.findViewById(R.id.btn_2_vertical);
    lineBtn3Vertical = (View) rootView.findViewById(R.id.line_btn3_vertical);
    btn3Vertical = (Button) rootView.findViewById(R.id.btn_3_vertical);
    llContainerVertical = (LinearLayout) rootView.findViewById(R.id.ll_container_vertical);
    sv = (ScrollView) rootView.findViewById(R.id.sv);
    llContainerContent = (LinearLayout) rootView.findViewById(R.id.ll_container);
}
 
Example #5
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
Example #6
Source File: BlurDrawableActivity.java    From BlurView with Apache License 2.0 6 votes vote down vote up
private void init() {
    mBlurDrawableRelativeLayout = (RelativeLayout) this.findViewById(R.id.blur_drawable_container);
    mBlurDrawableRelativeLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mBlurDrawableRelativeLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            mBlurDrawable = new BlurDrawable(BlurDrawableActivity.this);
            mBlurDrawable.drawableContainerId(R.id.blur_drawable_container)
                    .cornerRadius(10)
                    .blurRadius(10)
                    .overlayColor(Color.parseColor("#64ffffff"))
                    .offset(mBlurDrawableRelativeLayout.getLeft(), mBlurDrawableRelativeLayout.getTop() );
            mBlurDrawableRelativeLayout.setBackgroundDrawable(mBlurDrawable);
        }
    });

    mScrollView = (ScrollView) this.findViewById(R.id.sv);
    mScrollView.getViewTreeObserver().addOnScrollChangedListener(getOnScrollChangedListener());
}
 
Example #7
Source File: MDA_DraggedViewPager.java    From DraggedViewPager with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void notifyDataSetChanged() {
    int currentPageIndex = currentPage;

    container.removeAllViews();

    for (int i = 0; i < controller.getData().size(); i++) {
        View pageView = LayoutInflater.from(getContext()).inflate(controller.getPageLayoutRes(), container, false);
        //添加至主框架View
        container.addView(pageView);
        ScrollView scrollView = (ScrollView) pageView.findViewById(R.id.dvp_scroll_view);
        MDA_PageListLayout pageListLayout = new MDA_PageListLayout(getContext(), controller.getItemLayoutRes());
        //添加View
        scrollView.addView(pageListLayout);
        //设置页面索引
        pageListLayout.setPageIndex(i);
        controller.bindPageData(pageView, i);
        //设置数据
        pageListLayout.setData(controller.getPage(i).getData());
    }

    initDragEvent(DragUtils.DragViewType.ALL);

    scrollToPage(currentPageIndex);
}
 
Example #8
Source File: ScrollableHelper.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public void smoothScrollBy(int velocityY, int distance, int duration) {
    View scrollableView = getScrollableView();
    if (scrollableView instanceof AbsListView) {
        AbsListView absListView = (AbsListView) scrollableView;
        if (Build.VERSION.SDK_INT >= 21) {
            absListView.fling(velocityY);
        } else {
            absListView.smoothScrollBy(distance, duration);
        }
    } else if (scrollableView instanceof ScrollView) {
        ((ScrollView) scrollableView).fling(velocityY);
    }  else if (scrollableView instanceof NestedScrollView) {
        ((NestedScrollView) scrollableView).fling(velocityY);
    } else if (scrollableView instanceof RecyclerView) {
        ((RecyclerView) scrollableView).fling(0, velocityY);
    } else if (scrollableView instanceof WebView) {
        ((WebView) scrollableView).flingScroll(0, velocityY);
    }
}
 
Example #9
Source File: SublimeRecurrencePicker.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
public void updateView() {
    if (mCurrentView == CurrentView.RECURRENCE_OPTIONS_MENU) {
        mRecurrenceOptionCreator.setVisibility(View.GONE);
        llRecurrenceOptionsMenu.setVisibility(View.VISIBLE);

        // Current repeat option may have changed
        updateFlowLayout(mCurrentRecurrenceOption);

        // reset `scrollY` to 0
        final ScrollView scrollView
                = (ScrollView) llRecurrenceOptionsMenu.findViewById(R.id.svRecurrenceOptionsMenu);
        llRecurrenceOptionsMenu.post(new Runnable() {
            @Override
            public void run() {
                if (scrollView.getScrollY() != 0)
                    scrollView.fullScroll(ScrollView.FOCUS_UP);
            }
        });
    } else if (mCurrentView == CurrentView.RECURRENCE_CREATOR) {
        llRecurrenceOptionsMenu.setVisibility(View.GONE);
        mRecurrenceOptionCreator.setVisibility(View.VISIBLE);
    }
}
 
Example #10
Source File: FragmentLayout.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    if (container == null) {
        // We have different layouts, and in one of them this
        // fragment's containing frame doesn't exist.  The fragment
        // may still be created from its saved state, but there is
        // no reason to try to create its view hierarchy because it
        // won't be displayed.  Note this is not needed -- we could
        // just run the code below, where we would create and return
        // the view hierarchy; it would just never be used.
        return null;
    }

    ScrollView scroller = new ScrollView(getActivity());
    TextView text = new TextView(getActivity());
    int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            4, getActivity().getResources().getDisplayMetrics());
    text.setPadding(padding, padding, padding, padding);
    scroller.addView(text);
    text.setText(Shakespeare.DIALOGUE[getShownIndex()]);
    return scroller;
}
 
Example #11
Source File: ConvertToBitmapUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 将ScrollView转换为Bitmap
 * @param scrollView
 * @return
 */
public static Bitmap convertScrollViewToBitmap(ScrollView scrollView) {
    int h = 0;
    Bitmap bitmap = null;
    // 获取scrollview实际高度
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
        scrollView.getChildAt(i).setBackgroundColor(
                Color.parseColor("#ffffff"));
    }
    // 创建对应大小的bitmap
    bitmap = Bitmap.createBitmap(scrollView.getWidth(), h,
            Bitmap.Config.RGB_565);
    final Canvas canvas = new Canvas(bitmap);
    scrollView.draw(canvas);
    return bitmap;
}
 
Example #12
Source File: MainActivity.java    From astrobee_android with Apache License 2.0 5 votes vote down vote up
private static void scrollToBottom(final ScrollView sv) {
    sv.post(new Runnable() {
        @Override
        public void run() {
            sv.fullScroll(View.FOCUS_DOWN);
        }
    });
}
 
Example #13
Source File: MainActivity.java    From Locate-driver with GNU General Public License v3.0 5 votes vote down vote up
private void scrollTop() {
    final ScrollView scrollView = (ScrollView) this.findViewById(R.id.scrollview);

    scrollView.post(new Runnable() {
        public void run() {
            scrollView.scrollTo(0, 0);
        }
    });
}
 
Example #14
Source File: ConfirmOperationFragment.java    From hawkular-android-client with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    table = (TableLayout) view.findViewById(R.id.operation_param_table);
    execute = (Button) view.findViewById(R.id.execute);
    cancel = (Button) view.findViewById(R.id.cancel);
    operationDetail = (TextView) view.findViewById(R.id.operation_detail);
    custom = (SwitchCompat) view.findViewById(R.id.custom);
    scroll = (ScrollView) view.findViewById(R.id.scroll);

    resource = getResource();
    operation = getOperation();
    scroll.setVisibility(View.GONE);

    toolbar.setTitle(R.string.operation_confirm_title);

    setOperationDetail();

    BackendClient.of(ConfirmOperationFragment.this).getOperationProperties(new ConfirmOperationFragment.OperationPropertiesCallback(),
            operation, resource);

    execute.setOnClickListener(new ClickListner());
    cancel.setOnClickListener(new ClickListner());

    custom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked) {
                scroll.setVisibility(View.VISIBLE);
            } else {
                scroll.setVisibility(View.GONE);
            }
        }
    });
}
 
Example #15
Source File: LogFragment.java    From android-CardReader with Apache License 2.0 5 votes vote down vote up
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}
 
Example #16
Source File: LogFragment.java    From android-SwipeRefreshListFragment with Apache License 2.0 5 votes vote down vote up
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}
 
Example #17
Source File: ScrollableHelper.java    From ScrollableLayout with Apache License 2.0 5 votes vote down vote up
private static boolean isScrollViewTop(ScrollView scrollView) {
    if (scrollView != null) {
        int scrollViewY = scrollView.getScrollY();
        return scrollViewY <= 0;
    }
    return false;
}
 
Example #18
Source File: DNSProxyActivity.java    From personaldnsfilter with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasFocus) {
	super.onWindowFocusChanged(hasFocus);
	if (hasFocus && !scroll_locked) {
		logOutView.setSelection(logOutView.getText().length());
		scrollView.fullScroll(ScrollView.FOCUS_DOWN);
	}
}
 
Example #19
Source File: CategoryActivity.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
/**
 * todo.mb: consider refactoring to common logic with attributes and so on.
 */
private void addSmsTemplate(SmsTemplate t) {
    View v = x.inflater.new Builder(smsTemplatesLayout, R.layout.select_entry_simple_minus).withId(R.id.edit_sms_template, this).create();
    setSmsTemplateData(v, t);
    ImageView minusImageView = v.findViewById(R.id.plus_minus);
    minusImageView.setId(R.id.remove_sms_template);
    minusImageView.setOnClickListener(this);
    minusImageView.setTag(t.id);
    v.setTag(t);
    scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
 
Example #20
Source File: SearchFragment.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
protected void bindViews(View view) {
    swipeContainer = (SwipeRefreshLayout )view.findViewById(R.id.swipe_container);
    noSearchResultLayout = (ScrollView )view.findViewById(R.id.no_search_results_layout);
    searchButton = (ImageView )view.findViewById(R.id.ic_search_button);
    searchQuery = (EditText )view.findViewById(R.id.search_text);
    progressBar = (ProgressBar )view.findViewById(R.id.progress_bar);
    layoutNoNetwork = (ScrollView )view.findViewById(R.id.no_network_connection);
    layoutError = (ScrollView )view.findViewById(R.id.error);
    retryError = (TextView )view.findViewById(R.id.retry_error);
    retryNoNetwork = (TextView )view.findViewById(R.id.retry_no_network);
}
 
Example #21
Source File: RootNameserverFragment.java    From DNSHero with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ScrollView layout = (ScrollView) inflater.inflate(R.layout.fragment_root_nameserver, container, false);

    Bundle args = getArguments();
    Domain.RootNameserver root;
    if (getContext() == null || args == null || (root = (Domain.RootNameserver) args.getSerializable("root")) == null)
        return null;

    SuperTextView name = layout.findViewById(R.id.rootNsFragment_name);
    Utils.clickToCopy(name);
    name.setText(root.name);

    SuperTextView rtt = layout.findViewById(R.id.rootNsFragment_rtt);
    rtt.setHtml(R.string.rtt, Utils.formatRTT(root.rtt));

    final LinearLayout nameservers = layout.findViewById(R.id.rootNsFragment_nameservers);
    for (String nameserver : root.nameservers) {
        TextView text = (TextView) inflater.inflate(R.layout.item_secondary_text, nameservers, false);
        text.setText(nameserver);
        Utils.clickToCopy(text);

        nameservers.addView(text);
    }

    final ImageButton toggleNs = layout.findViewById(R.id.rootNsFragment_toggleNs);
    toggleNs.setOnClickListener(v -> CommonUtils.handleCollapseClick(toggleNs, nameservers));

    GlueView glue = layout.findViewById(R.id.rootNsFragment_glue);
    glue.setGlue(root.glue);

    return layout;
}
 
Example #22
Source File: LogFragment.java    From android-play-places with Apache License 2.0 5 votes vote down vote up
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}
 
Example #23
Source File: LogFragment.java    From graphics-samples with Apache License 2.0 5 votes vote down vote up
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}
 
Example #24
Source File: PullToRefreshScrollView.java    From letv with Apache License 2.0 5 votes vote down vote up
protected boolean isReadyForPullEnd() {
    View scrollViewChild = ((ScrollView) this.mRefreshableView).getChildAt(0);
    if (scrollViewChild == null) {
        return false;
    }
    if (((ScrollView) this.mRefreshableView).getScrollY() >= scrollViewChild.getHeight() - getHeight()) {
        return true;
    }
    return false;
}
 
Example #25
Source File: BaseActivity.java    From Android-Bootstrap with MIT License 5 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView);

    if (scrollView != null) {
        scrollView.addView(LayoutInflater.from(this).inflate(getContentLayoutId(), scrollView, false));
    }

    ButterKnife.bind(this);
}
 
Example #26
Source File: LayoutHelper.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static ScrollView.LayoutParams createScroll(int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.leftMargin = AndroidUtilities.dp(leftMargin);
    layoutParams.topMargin = AndroidUtilities.dp(topMargin);
    layoutParams.rightMargin = AndroidUtilities.dp(rightMargin);
    layoutParams.bottomMargin = AndroidUtilities.dp(bottomMargin);
    return layoutParams;
}
 
Example #27
Source File: BotKeyboardView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public BotKeyboardView(Context context) {
    super(context);

    setOrientation(VERTICAL);

    scrollView = new ScrollView(context);
    addView(scrollView);
    container = new LinearLayout(context);
    container.setOrientation(VERTICAL);
    scrollView.addView(container);
    AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_chat_emojiPanelBackground));

    setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
}
 
Example #28
Source File: LogFragment.java    From android-BasicNetworking with Apache License 2.0 5 votes vote down vote up
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}
 
Example #29
Source File: JSResponderTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
 
Example #30
Source File: DrMIPSActivity.java    From drmips with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates the state of the simulation controls and the values displayed.
 * Updates the enabled/disabled states of the simulation controls.
 * It also refreshes the values displayed in the tables and the datapath,
 * and scrolls the assembled code table to make the current instruction visible.
 */
private void refreshValues() {
	updateStepBackEnabled();
	updateStepEnabled();

	refreshRegistersTableValues();
	refreshDataMemoryTableValues();
	refreshAssembledCodeTableValues();
	refreshExecTableValues();
	if(datapath != null) datapath.refresh();

	// Scroll the assembled code table to the current instruction
	int index = getCPU().getPC().getCurrentInstructionIndex();
	if(index >= 0) {
		final ScrollView scroll = (ScrollView)findViewById(R.id.tblAssembledCodeScroll);
		final View row = tblAssembledCode.getChildAt(index + 1);

		// Scroll only if the row is out of view
		if(row != null && (row.getTop() < scroll.getScrollY() ||
		                   row.getBottom() > (scroll.getScrollY() + scroll.getHeight()))) {
			scroll.post(new Runnable() {
				@Override
				public void run() {
					if(row.getTop() < scroll.getScrollY()) {
						// Row is above the visible area
						// > scroll up until the row is visible at the top of the ScrollView
						scroll.smoothScrollTo(0, row.getTop());
					}
					else {
						// Row is below the visible area
						// > scroll down until the row is visible at the bottom of the ScrollView
						scroll.smoothScrollTo(0, row.getBottom() - scroll.getHeight());
					}
				}
			});
		}
	}
}