Java Code Examples for android.widget.ScrollView#setOnTouchListener()
The following examples show how to use
android.widget.ScrollView#setOnTouchListener() .
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: SettingsFragment.java From Anti-recall with GNU Affero General Public License v3.0 | 6 votes |
private void initBottomNavigationBar(ScrollView view) { // 底部navigation bar的show hide view.setOnTouchListener((v, event) -> { NavigationTabBar navigationTabBar = getActivity().findViewById(R.id.ntb); switch (event.getAction()) { case MotionEvent.ACTION_MOVE: if (event.getHistorySize() < 1) return false; float y = event.getY(); float historicalY = event.getHistoricalY(event.getHistorySize() - 1); if (y > historicalY) navigationTabBar.show(); else navigationTabBar.hide(); } return false; }); }
Example 2
Source File: ScrollViewFragment.java From Bounce with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_scroll_view, container, false); header = root.findViewById(R.id.header_image_view); scrollView = (ScrollView) root.findViewById(R.id.scroll_view); BounceTouchListener bounceTouchListener = BounceTouchListener.create(scrollView, R.id.content, new BounceTouchListener.OnTranslateListener() { @Override public void onTranslate(float translation) { if (translation > 0) { float scale = ((2 * translation) / header.getMeasuredHeight()) + 1; header.setScaleX(scale); header.setScaleY(scale); } } } ); scrollView.setOnTouchListener(bounceTouchListener); return root; }
Example 3
Source File: DetailActivity.java From EasyTransition with Apache License 2.0 | 5 votes |
private void startBackAnim() { // forbidden scrolling ScrollView sv = (ScrollView) findViewById(R.id.sv); sv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); // start our anim ivAdd.animate() .setDuration(200) .scaleX(0) .scaleY(0); layoutAbout.animate() .setDuration(300) .alpha(0) .translationY(-30) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // transition exit after our anim EasyTransition.exit(DetailActivity.this, 800, new DecelerateInterpolator()); } }); }
Example 4
Source File: ScrollViewActivity.java From Rocko-Android-Demos with Apache License 2.0 | 4 votes |
private void init() { scrollView = (ScrollView) findViewById(R.id.scroll_view); AutoScrollHelper autoScrollHelper = new ScrollViewAutoScrollHelper(scrollView); autoScrollHelper.setEnabled(true); scrollView.setOnTouchListener(autoScrollHelper); }
Example 5
Source File: EditActivity.java From Swiftnotes with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Android version >= 18 -> set orientation fullUser if (Build.VERSION.SDK_INT >= 18) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Android version < 18 -> set orientation fullSensor else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Initialize colours and font sizes arrays colourArr = getResources().getStringArray(R.array.colours); colourArrResId = new int[colourArr.length]; for (int i = 0; i < colourArr.length; i++) colourArrResId[i] = Color.parseColor(colourArr[i]); fontSizeArr = new int[] {14, 18, 22}; // 0 for small, 1 for medium, 2 for large fontSizeNameArr = getResources().getStringArray(R.array.fontSizeNames); setContentView(R.layout.activity_edit); // Init layout components toolbar = (Toolbar)findViewById(R.id.toolbarEdit); titleEdit = (EditText)findViewById(R.id.titleEdit); bodyEdit = (EditText)findViewById(R.id.bodyEdit); relativeLayoutEdit = (RelativeLayout)findViewById(R.id.relativeLayoutEdit); ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView); imm = (InputMethodManager) this.getSystemService(INPUT_METHOD_SERVICE); if (toolbar != null) initToolbar(); // If scrollView touched and note body doesn't have focus -> request focus and go to body end scrollView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (!bodyEdit.isFocused()) { bodyEdit.requestFocus(); bodyEdit.setSelection(bodyEdit.getText().length()); // Force show keyboard imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); return true; } return false; } }); // Get data bundle from MainActivity bundle = getIntent().getExtras(); if (bundle != null) { // If current note is not new -> initialize colour, font, hideBody and EditTexts if (bundle.getInt(NOTE_REQUEST_CODE) != NEW_NOTE_REQUEST) { colour = bundle.getString(NOTE_COLOUR); fontSize = bundle.getInt(NOTE_FONT_SIZE); hideBody = bundle.getBoolean(NOTE_HIDE_BODY); titleEdit.setText(bundle.getString(NOTE_TITLE)); bodyEdit.setText(bundle.getString(NOTE_BODY)); bodyEdit.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize); if (hideBody) menuHideBody.setTitle(R.string.action_show_body); } // If current note is new -> request keyboard focus to note title and show keyboard else if (bundle.getInt(NOTE_REQUEST_CODE) == NEW_NOTE_REQUEST) { titleEdit.requestFocus(); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } // Set background colour to note colour relativeLayoutEdit.setBackgroundColor(Color.parseColor(colour)); } initDialogs(this); }