Java Code Examples for android.widget.ScrollView

The following examples show how to use android.widget.ScrollView. These examples are extracted from open source projects. 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
@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 2
Source Project: weex   Source File: WXRenderStatement.java    License: 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 3
Source Project: DialogUtil   Source File: IosAlertDialogHolder.java    License: 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 4
Source Project: sensors-samples   Source File: CardStreamLinearLayout.java    License: 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 5
Source Project: BottomDialog   Source File: BottomDialog.java    License: 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 6
Source Project: APDE   Source File: SketchFile.java    License: 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 7
/**
 * 将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 8
Source Project: SublimePicker   Source File: SublimeRecurrencePicker.java    License: 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 9
Source Project: DraggedViewPager   Source File: MDA_DraggedViewPager.java    License: 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 10
Source Project: BlurView   Source File: BlurDrawableActivity.java    License: 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 11
Source Project: DanDanPlayForAndroid   Source File: ScrollableHelper.java    License: 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 12
Source Project: Locate-driver   Source File: MainActivity.java    License: 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 13
Source Project: cwac-mediarouter   Source File: PlaybackFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState) {
  scroll=
      (ScrollView)inflater.inflate(R.layout.activity_main, container,
                                   false);

  transcript=(TextView)scroll.findViewById(R.id.transcript);

  logToTranscript("Started");

  return(scroll);
}
 
Example 14
Source Project: media-samples   Source File: LogFragment.java    License: 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 15
Source Project: xDrip   Source File: UpdateActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void downloadNow(View myview) {
    if (DOWNLOAD_URL.length() > 0) {
        if (prefs.getBoolean(useInternalDownloaderPrefsName, true)) {
            if (checkPermissions()) {
                if (downloading) {
                    JoH.static_toast_long(this, "Already downloading!");
                } else {
                    downloading = true;
                    JoH.static_toast_long(this, "Attempting background download...");
                    mScrollView.post(new Runnable() {
                        public void run() {
                            mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
                        }
                    });
                    new AsyncDownloader().executeOnExecutor(xdrip.executor);

                }
            } else {
                JoH.static_toast_long(this, "Need permission to download file");
            }
        } else {
            viewIntentDownload(DOWNLOAD_URL);
            finish();
        }

    } else {
        Log.e(TAG, "Download button pressed but no download URL");
    }
}
 
Example 16
Source Project: Focus   Source File: PostDetailFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void initView(){

        layers = new int[]{
                R.id.header_container,
                R.id.post_content,
        };

        //根据偏好设置的背景颜色,设置标题栏位置的背景颜色
        if (!SkinPreference.getInstance().getSkinName().equals("night")){
//            helper.setBackgroundColor(R.id.container, PostSetting.getBackgroundInt(context));
            postTitle.setBackgroundColor(PostSetting.getBackgroundInt(getContext()));
            postTurn.setBackgroundColor(PostSetting.getBackgroundInt(getContext()));
        }

        //设置文章内容
        PostUtil.setContent(getContext(), feedItem, postContent,null);
        postTitle.setText(feedItem.getTitle());
        postTime.setText( DateUtil.getTimeStringByInt(feedItem.getDate()));
        feedName.setText( feedItem.getFeedName());

        if (!feedItem.isRead()) {
            //如果这个文章没有阅读过则滚动到顶部
            postTurn.fullScroll(ScrollView.FOCUS_UP);
        }


        initListener();
    }
 
Example 17
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 18
Source Project: MyBlogDemo   Source File: NestedScrollView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    final NestedScrollView nsvHost = (NestedScrollView) host;
    event.setClassName(ScrollView.class.getName());
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    final boolean scrollable = nsvHost.getScrollRange() > 0;
    record.setScrollable(scrollable);
    record.setScrollX(nsvHost.getScrollX());
    record.setScrollY(nsvHost.getScrollY());
    record.setMaxScrollX(nsvHost.getScrollX());
    record.setMaxScrollY(nsvHost.getScrollRange());
}
 
Example 19
Source Project: GreenDamFileExploere   Source File: FileListPageFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void autoMoveToBottom() {
    mTopNaviScroll.post(new Runnable() {
        @Override
        public void run() {
            mTopNaviScroll.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    });
}
 
Example 20
Source Project: android-SlidingTabsColors   Source File: LogFragment.java    License: 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 21
@Override
protected void onCreate(Bundle savedInstanceState) {

	PrefsUtility.applyTheme(this);

	super.onCreate(savedInstanceState);

	if (getIntent() != null && getIntent().hasExtra("isSelfPost")
			&& getIntent().getBooleanExtra("isSelfPost", false)){
		setTitle(R.string.edit_post_actionbar);
		isSelfPost = true;
	} else {
		setTitle(R.string.edit_comment_actionbar);
	}
	textEdit = (EditText) getLayoutInflater().inflate(R.layout.comment_edit, null);

	if(getIntent() != null && getIntent().hasExtra("commentIdAndType")) {
		commentIdAndType = getIntent().getStringExtra("commentIdAndType");
		textEdit.setText(getIntent().getStringExtra("commentText"));

	} else if(savedInstanceState != null && savedInstanceState.containsKey("commentIdAndType")) {
		textEdit.setText(savedInstanceState.getString("commentText"));
		commentIdAndType = savedInstanceState.getString("commentIdAndType");
	}

	final ScrollView sv = new ScrollView(this);
	sv.addView(textEdit);
	setBaseActivityContentView(sv);
}
 
Example 22
Source Project: support   Source File: LargeHeightImageDisplayFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setBackgroundColor(Color.WHITE);
    scrollView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mContainer = linearLayout;
    scrollView.addView(linearLayout);
    return scrollView;
}
 
Example 23
private void showDialogForView(View view) {
    Dialog dialog = new Dialog(mContext);
    dialog.setTitle(R.string.certtitle);
    ScrollView scrollView = new ScrollView(mContext);
    scrollView.addView(view);
    dialog.addContentView(scrollView,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
    dialog.show();
}
 
Example 24
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    ScrollView sv = new ScrollView(c);
    LinearLayout ll = new LinearLayout(c);
    HashSet<String> selectedSet = new HashSet<String>();

    if (answer == null)
        answer = "";
    // we've got a problem if there are TOKEN_DELIMITERs in the value!
    // since getAnswer separates responses using TOKEN_DELIMITER
    String[] values = answer.split(TOKEN_DELIMITER);
    for (String val : values) {
        selectedSet.add(val);
    }

    ll.setOrientation(LinearLayout.VERTICAL);
    cblist = new ArrayList<CheckBox>();
    for (String choice : labels()) {
        CheckBox cb = new CheckBox(c);
        cb.setTag(getValueFromLabel(choice));
        cb.setText(choice);
        cb.setChecked(selectedSet.contains(String.valueOf(cb.getTag())));
        cblist.add(cb);
        ll.addView(cb);
    }
    sv.addView(ll, new ViewGroup.LayoutParams(-1, -1));
    return encapsulateQuestion(c, sv);
}
 
Example 25
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.scrollview_overscroll_demo, null, false);
    initHorizontalScrollView((HorizontalScrollView) fragmentView.findViewById(R.id.horizontal_scroll_view));
    initVerticalScrollView((ScrollView) fragmentView.findViewById(R.id.vertical_scroll_view));
    return fragmentView;
}
 
Example 26
Source Project: YTPlayer   Source File: ErrorActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_error);

    setTitle("Send Report");

    sendLogs = findViewById(R.id.sendLogs);
    crashLayout = findViewById(R.id.crashLayout);
    editText = findViewById(R.id.reportText);

    crashDetails =  CustomActivityOnCrash.getStackTraceFromIntent(getIntent());

    crashLayout.setOnClickListener(v -> {
        ScrollView nestedScrollView = new ScrollView(this);
        TextView textView = new TextView(ErrorActivity.this);
        textView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.setPadding(20,20,20,20);
        textView.setTextSize(13);
        textView.setText(crashDetails);
        nestedScrollView.addView(textView);
        final AlertDialog.Builder alert= new AlertDialog.Builder(ErrorActivity.this);
        alert.setTitle("Stack Trace");
        alert.setView(nestedScrollView);
        alert.setPositiveButton("OK", null);
        alert.show();
    });
}
 
Example 27
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_venue, container,
            false);
    MapsInitializer.initialize(getActivity().getApplicationContext());
    scrollView = (ScrollView) v.findViewById(R.id.venue_scrollview);
    mMapView = (VenueMapView) v.findViewById(R.id.mapView);
    TextView address = (TextView) v.findViewById(R.id.venue_detail);

    sharedPref = getActivity().getApplicationContext()
            .getSharedPreferences(PREFERENCES_FILE_NAME, Context.MODE_PRIVATE);
    venueAddress = sharedPref.getString(VENUE_TAG, null);
    address.setText(venueAddress);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume();// needed to get the map to display immediately

    status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());

    googleMap = mMapView.getMap();

    new MapPlotting().execute();

    return v;
}
 
Example 28
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 29
Source Project: letv   Source File: PullToRefreshScrollView.java    License: 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 30
Source Project: android-BasicNetworking   Source File: LogFragment.java    License: 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;
}