private void init() { totalPages = 2; Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight(); // mBookView = new CurlView(mContext, screenWidth, screenHeight); // prepare view to take all screenshoot LinearLayout ll = new LinearLayout(mContext); ll.setOrientation(LinearLayout.VERTICAL); LayoutInflater factory = LayoutInflater.from(mContext); View view = factory.inflate(R.layout.scrach_page, null); ll.addView(view, screenWidth, screenHeight); View view2 = factory.inflate(R.layout.scrach_page, null); ll.addView(view2, screenWidth, screenHeight); // hide scrollview's commponent to have clear bitmap scrollView = new ScrollView(mContext); scrollView.addView(ll); scrollView.setVerticalScrollBarEnabled(false); scrollView.setHorizontalScrollBarEnabled(false); scrollView.setFadingEdgeLength(0); addView(scrollView); // add true view and some actions View view3 = factory.inflate(R.layout.scrach_page, null); addView(view3, screenWidth, screenHeight); View view4 = factory.inflate(R.layout.scrach_page, null); addView(view4, screenWidth, screenHeight); addView(mBookView); mBookView.setView(view3, view4); // view 1 }
private void dialogie(String s) { if (s == null || s.length() == 0) return; AlertDialog ad = new AlertDialog.Builder(me).create(); ad.setCancelable(true); ad.setCanceledOnTouchOutside(true); ad.setTitle("Linkification view"); LinearLayout rl = new LinearLayout(me); rl.setBackgroundColor(Color.WHITE); rl.setPadding(scalemex(5), scalemex(25), scalemex(5), scalemex(25)); TextView tv; tv = new TextView(me); rl.addView(tv); tv.setBackgroundColor(Color.WHITE); tv.setTextColor(Color.BLACK); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19f); tv.setText(s); Linkify.addLinks(tv, Linkify.ALL); ScrollView ho = new ScrollView(me); ho.addView(rl); ad.setView(ho); ad.show(); }
/** 截取scrollview的屏幕 * */ public static Bitmap getBitmapByView(ScrollView scrollView) { int h = 0; Bitmap bitmap = null; // 获取listView实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); // scrollView.getChildAt(i).setBackgroundResource(R.drawable.bg3); } Log.d(TAG, "实际高度:" + h); Log.d(TAG, " 高度:" + scrollView.getHeight()); // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); // 测试输出 FileOutputStream out = null; try { out = new FileOutputStream("/sdcard/screen_test.png"); } catch (FileNotFoundException e) { e.printStackTrace(); } try { if (null != out) { bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); out.flush(); out.close(); } } catch (IOException e) { // TODO: handle exception } return bitmap; }
private void loadUserInfo() { try { connMgr = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { noInternetLayout.setVisibility(View.GONE); scrollViewLayout.setVisibility(View.VISIBLE); noInternetLayoutInfo.setVisibility(View.GONE); // fetch data if (sUserId != null) { new ProfileTask().execute(sUserId); } else if (sPagesId != null) { new ProfileTask().execute(sPagesId); } } else { // display error noInternetLayoutInfo.setVisibility(View.VISIBLE); scrollViewLayout.setVisibility(View.GONE); noInternetLayout.setVisibility(View.VISIBLE); } } catch (Exception ex) { ex.printStackTrace(); noInternetLayoutInfo.setVisibility(View.VISIBLE); scrollViewLayout.setVisibility(View.GONE); noInternetLayout.setVisibility(View.VISIBLE); } }
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false"); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false"); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false"); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action); break; } return false; }
@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; }
private void setupContent(LinearLayout contentPanel) { mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView); mScrollView.setFocusable(false); // Special case for users that only want to display a String mMessageView = (TextView) mWindow.findViewById(R.id.message); if (mMessageView == null) { return; } if (mMessage != null) { mMessageView.setText(mMessage); } else { mMessageView.setVisibility(View.GONE); mScrollView.removeView(mMessageView); if (mListView != null) { contentPanel.removeView(mWindow.findViewById(R.id.scrollView)); contentPanel.addView(mListView, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); contentPanel.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f)); } else { contentPanel.setVisibility(View.GONE); } } }
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; }
private void process_content_view() { if (ContentView != null) { ScrollView sv = (ScrollView) findViewById(R.id.mindpin_alert_dialog_content_panel_scrollView); sv.removeAllViews(); sv.addView(ContentView); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_reserve_seats); final Button cancel = (Button) findViewById(R.id.cancel_res_button); cancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View V) { intnt = new Intent(); setResult(RESULT_OK, intnt); finish(); } }); final Button save = (Button) findViewById(R.id.save_res_button); save.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { intnt = new Intent(); setResult(RESULT_OK, intnt); finish(); } }); TableLayout tl = CreateSeatsLayout(); ScrollView sc = (ScrollView) findViewById(R.id.reserve_scroll); sc.addView(tl); }
private View createView() { ArrayList<String> addrs = getNetworkAddresses(); ScrollView parent = new ScrollView(this); int fill = LinearLayout.LayoutParams.FILL_PARENT; int wrap = LinearLayout.LayoutParams.WRAP_CONTENT; LinearLayout.LayoutParams fillAll = new LinearLayout.LayoutParams(fill, fill); parent.setLayoutParams(fillAll); layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LinearLayout.LayoutParams(fill, wrap)); parent.addView(layout); text(R.string.desc_setup_wifi, 20); text(R.string.desc_goto_settings); text(R.string.desc_enable_kbd); text(R.string.desc_toch_input_field); text(R.string.desc_change_input_method); text("", 15); if (addrs.size() == 0) { text("Enable wifi or GPRS/3G", 20); } else if (addrs.size() == 1) { text(getString(R.string.desc_connect_to_one, addrs.get(0), port), 20); } else { text(R.string.desc_connect_to_any); for (String addr : addrs) { text("http://" + addr + ":" + port, 20); } } text(R.string.desc_warn); text("", 15); text(R.string.desc_alt_usb_cable, 20); text(R.string.desc_adb_from_sdk); text(getString(R.string.desc_cmdline, port, port), 15); text(getString(R.string.desc_connect_local, port), 15); return parent; }
protected void a() { Object localObject = (ScrollView) g.a(mContext).inflate(2130903099, null); d = ((ScrollView) localObject).findViewById(2131362077); e = d.findViewById(2131362078); f = d.findViewById(2131362082); f.setVisibility(8); g = d.findViewById(2131362083); g.setVisibility(8); n = new ha(this, mContext); n.a(); a(e); i = ((ScrollView) localObject).findViewById(2131362086); j = i.findViewById(2131362078); k = i.findViewById(2131362082); a = new e(mContext); a(j, 0); a(k, 1); setContentView((View) localObject); ((ScrollView) localObject).setScrollbarFadingEnabled(false); if (!(ad.a(mContext).ak() | ad.a(mContext).am())) { i.setVisibility(8); ((ScrollView) localObject).findViewById(2131362084).setVisibility(8); } localObject = null; if (FileExplorerActivity.J() != null) { localObject = FileExplorerActivity.J().z(); } if ((localObject != null) && (am.aN((String) localObject))) { a(1); a(2); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = activity.getActionBar(); View view = actionBar.getCustomView(); ImageView title_image = (ImageView) view.findViewById(R.id.title_image); title_image.setBackgroundResource(R.drawable.substancea_cs); ScrollView sv = new ScrollView(activity); sv.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setFillViewport(true); LinearLayout lay = new LinearLayout(activity); lay.setOrientation(LinearLayout.VERTICAL); lay.setBackgroundColor(Color.WHITE); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); sv.addView(lay, params); // setContentView(sv); search_lay.setOnClickListener(searchLis); search_btn.setOnClickListener(searchLis); showLinelay = new LinearLayout(activity); ((LinearLayout) showLinelay).setOrientation(LinearLayout.VERTICAL); lay.addView(showLinelay, params); initNet(); loadData(new RequestPram()); }
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; }
/** * 设置新闻详情 * * @param index */ public void ShowNewsDetail(NewsDetailModel model) { this.model = model; if (model.isFavorate) { favoritBtn.setText("取消收藏"); } else { favoritBtn.setText("收藏"); } scrollView.scrollTo(0, 0); scrollView.smoothScrollTo(0, 0); LogInfo.LogOut("OnlineNewsAdapter", "ShowNews-->pos:" + pos); final NewsDetailModel news = model; mTitle.setText(news.title); mTimeProvenance.setText( (TextUtils.isEmpty(news.cFrom) ? "" : " 来源: " + news.cFrom) + "\t" + news.cTime); LogInfo.LogOut("字数:" + (news.content == null ? 0 : news.content.length())); mDetails.setText(""); postDelayed( new Runnable() { @Override public void run() { setChangeLine(news.content); } }, 50); if (TextUtils.isEmpty(news.imgUrl)) { mNewsImage.setVisibility(GONE); } else { mNewsImage.setVisibility(VISIBLE); ImageEngine.setImageBitmap(news.imgUrl, mNewsImage, R.drawable.ic_launcher, -1); } }
@Override public void run() { int off = mLayout.getMeasuredHeight() - sView.getHeight(); if (off > 0) { sView.scrollTo(0, off); // 改变滚动条的位置 } }
public void reset() { if (null != mScrollText) { mScrollText.setVisibility(View.GONE); } if (null != mImageView) { mImageView.setVisibility(View.GONE); } if (null != mAudioPlayer) { stopAudio(); } if (null != mVideoView) { stopVideo(); mVideoView.setVisibility(View.GONE); } if (null != mTextView) { mTextView.setVisibility(View.GONE); } if (mScrollViewPort != null) { mScrollViewPort.scrollTo(0, 0); mScrollViewPort.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0, 0)); } }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_frag); if (savedInstanceState == null) { FragmentManager manager = getFragmentManager(); // Start transaction FragmentTransaction transaction = manager.beginTransaction(); // Create fragments menu = new MenuFragment(); main = new NewsListFragment(); top = new TopFragment(); // Add fragments transaction.add(RIGHT_FRAG, main); transaction.add(LEFT_FRAG, menu); transaction.add(BOTTOM_FRAG, top); transaction.commit(); } if (!ObjectStorage.menuHidden) { ScrollView scrollview = (ScrollView) findViewById(R.id.fragleft); scrollview.setVisibility(View.VISIBLE); FrameLayout menuFrame = (FrameLayout) findViewById(R.id.fragmentcontainerleft); menuFrame.setVisibility(View.VISIBLE); } // For convienence get the list of images early on... Slow connection propogation // new GetImageUrlTask().execute(); }
public void onFinishInflate() { if (callbackProcs != null && callbackProcs[CB_FINISH_INFLATE] != null) { super.onFinishInflate(); Script.callMethod(callbackProcs[CB_FINISH_INFLATE], "call"); } else { super.onFinishInflate(); } }
@Test public void shouldSmoothScrollTo() throws Exception { ScrollView scrollView = new ScrollView(null); scrollView.smoothScrollTo(7, 6); assertEquals(7, scrollView.getScrollX()); assertEquals(6, scrollView.getScrollY()); }
public void onScrollChanged(int l, int t, int oldl, int oldt) { if (callbackProcs != null && callbackProcs[CB_SCROLL_CHANGED] != null) { super.onScrollChanged(l, t, oldl, oldt); Script.callMethod(callbackProcs[CB_SCROLL_CHANGED], "call", new Object[] {l, t, oldl, oldt}); } else { super.onScrollChanged(l, t, oldl, oldt); } }
public void onAnimationEnd() { if (callbackProcs != null && callbackProcs[CB_ANIMATION_END] != null) { super.onAnimationEnd(); Script.callMethod(callbackProcs[CB_ANIMATION_END], "call"); } else { super.onAnimationEnd(); } }
public void onFinishTemporaryDetach() { if (callbackProcs != null && callbackProcs[CB_FINISH_TEMPORARY_DETACH] != null) { super.onFinishTemporaryDetach(); Script.callMethod(callbackProcs[CB_FINISH_TEMPORARY_DETACH], "call"); } else { super.onFinishTemporaryDetach(); } }
public void onWindowVisibilityChanged(int visibility) { if (callbackProcs != null && callbackProcs[CB_WINDOW_VISIBILITY_CHANGED] != null) { super.onWindowVisibilityChanged(visibility); Script.callMethod(callbackProcs[CB_WINDOW_VISIBILITY_CHANGED], "call", visibility); } else { super.onWindowVisibilityChanged(visibility); } }
public void onWindowFocusChanged(boolean hasWindowFocus) { if (callbackProcs != null && callbackProcs[CB_WINDOW_FOCUS_CHANGED] != null) { super.onWindowFocusChanged(hasWindowFocus); Script.callMethod(callbackProcs[CB_WINDOW_FOCUS_CHANGED], "call", hasWindowFocus); } else { super.onWindowFocusChanged(hasWindowFocus); } }
public void onSizeChanged(int w, int h, int oldw, int oldh) { if (callbackProcs != null && callbackProcs[CB_SIZE_CHANGED] != null) { super.onSizeChanged(w, h, oldw, oldh); Script.callMethod(callbackProcs[CB_SIZE_CHANGED], "call", new Object[] {w, h, oldw, oldh}); } else { super.onSizeChanged(w, h, oldw, oldh); } }
@Override protected void onProgressUpdate(String... values) { TextView tvResponse = (TextView) mainActivity.findViewById(R.id.tvResponse); ScrollView scrollView = (ScrollView) mainActivity.findViewById(R.id.scrollView1); tvResponse.append(values[0] + "\n"); scrollView.fullScroll(ScrollView.FOCUS_DOWN); }
public void onRestoreInstanceState(android.os.Parcelable state) { if (callbackProcs != null && callbackProcs[CB_RESTORE_INSTANCE_STATE] != null) { super.onRestoreInstanceState(state); Script.callMethod(callbackProcs[CB_RESTORE_INSTANCE_STATE], "call", state); } else { super.onRestoreInstanceState(state); } }
public void onStartTemporaryDetach() { if (callbackProcs != null && callbackProcs[CB_START_TEMPORARY_DETACH] != null) { super.onStartTemporaryDetach(); Script.callMethod(callbackProcs[CB_START_TEMPORARY_DETACH], "call"); } else { super.onStartTemporaryDetach(); } }
public void onDraw(android.graphics.Canvas canvas) { if (callbackProcs != null && callbackProcs[CB_DRAW] != null) { super.onDraw(canvas); Script.callMethod(callbackProcs[CB_DRAW], "call", canvas); } else { super.onDraw(canvas); } }