protected void onPostExecute(String log) { // Get a reference to the activity if it is still there. LogActivity logActivity = refLogActivity.get(); if (logActivity == null || logActivity.isFinishing()) { return; } logActivity.mLog.setText(log); if (logActivity.mShareIntent != null) { logActivity.mShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, log); } // Scroll to bottom logActivity.mScrollView.post(() -> logActivity.mScrollView.scrollTo(0, logActivity.mLog.getBottom())); }
public void run() { scrollLogs.smoothScrollTo(0, txtLogs.getBottom()); } });
void startAnimation(){ TextView textView1=(TextView) findViewById(R.id.textView1); TextView textView2=(TextView) findViewById(R.id.textView2); Animation animation=new TranslateAnimation(0, 0, 0, textView1.getBottom()-textView2.getBottom()); animation.setDuration(1000); animation.setFillAfter(true); animation.setInterpolator(new BounceInterpolator()); textView2.startAnimation(animation); }
/** * Append message into log prefixing with duration since start of location requests. */ private void log(String msg) { double duration = mRequestStartTime != 0 ? (SystemClock.elapsedRealtime() - mRequestStartTime) / 1e3 : 0d; mLog.append(String.format(Locale.US, "\n[%06.2f]: %s", duration, msg)); mScrollView.smoothScrollBy(0, mLog.getBottom()); }
/** * Append message into log prefixing with duration since start of location requests. */ private void log(String msg) { double duration = mRequestStartTime != 0 ? (SystemClock.elapsedRealtime() - mRequestStartTime) / 1e3 : 0d; mLog.append(String.format(Locale.US, "\n[%06.2f]: %s", duration, msg)); mScrollView.smoothScrollBy(0, mLog.getBottom()); }
@Override public void onDraw(Canvas canvas) { super.onDraw(canvas); if (bitmap == null) { return; } canvas.drawBitmap(this.bitmap, this.x, this.y, holePaint); final boolean inTop = inTop(); final float lineX = this.x + this.bitmap.getWidth() / 2; final float lineY = this.y + (inTop ? this.bitmap.getHeight() + spacing : -spacing); final float lineYEnd = inTop ? this.text.getTop() - spacing : text.getBottom() + spacing; canvas.drawLine(lineX, lineY, lineX, lineYEnd, paint); }
@Override public void run() { tvLeft = textView.getLeft(); tvTop = textView.getTop(); tvRight = textView.getRight(); tvBottom = textView.getBottom(); first = false; textView.setText(tvLeft + "," + tvTop + "," + tvRight + "," + tvBottom); } });
@Override public boolean onTouch(View v, MotionEvent event) { int x = Math.round(event.getX()); int y = Math.round(event.getY()); for (int i = 0; i < getChildCount(); i++) { TextView child = (TextView) getChildAt(i); if (y > child.getTop() && y < child.getBottom()) { MemberLetterEvent letterEvent = new MemberLetterEvent(); letterEvent.letter = child.getText().toString().charAt(0); EventBus.getDefault().post(letterEvent); } } return true; } });
TextView tv = (TextView)findViewById(R.id.textView1); Rect bounds = new Rect(tv.getLeft(), tv.getTop(), tv.getRight(), tv.getBottom());
@Override public void initDataAndEvent() { mToolbar.setNavigationOnClickListener(v -> pop()); mToolbar.setOnMenuItemClickListener(this); mTimelineAdapter = new TopicTimelineAdapter(getContext()); mRecyclerTimeline.setAdapter(mTimelineAdapter); mRecyclerTimeline.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerTimeline.setNestedScrollingEnabled(false); mScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> { if (scrollY > mTxtTopicTime.getBottom()) { mToolbarHeader.setVisibility(View.VISIBLE); mToolbar.setTitle(""); } else { mToolbarHeader.setVisibility(View.GONE); mToolbar.setTitle(getText(R.string.menu_topic_detail)); } }); }
private void invisible() { int cx = (ivMeinv.getLeft() + ivMeinv.getRight()) / 2; int cy = (ivMeinv.getTop() + ivMeinv.getBottom()) / 2; int initialRadius = ivMeinv.getWidth(); Animator anim = ViewAnimationUtils.createCircularReveal(ivMeinv, cx, cy, initialRadius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); ivMeinv.setVisibility(View.INVISIBLE); } }); anim.start(); }
private void visible() { int cx = (ivMeinv.getLeft() + ivMeinv.getRight()) / 2; int cy = (ivMeinv.getTop() + ivMeinv.getBottom()) / 2; int initialRadius = ivMeinv.getWidth() + ivMeinv.getHeight(); Animator anim = ViewAnimationUtils.createCircularReveal(ivMeinv, cx, cy, 0, initialRadius); ivMeinv.setVisibility(View.VISIBLE); anim.start(); }
private static void setTextViewData(TextView view, TextResizeData data, float fontSize) { view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); view.setPadding(data.paddingLeft, data.paddingTop, data.paddingRight, data.paddingBottom); view.setRight(view.getLeft() + data.width); view.setBottom(view.getTop() + data.height); view.setTextColor(data.textColor); int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); }
private static void setTextViewData(TextView view, TextResizeData data, float fontSize) { view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); view.setPadding(data.paddingLeft, data.paddingTop, data.paddingRight, data.paddingBottom); view.setRight(view.getLeft() + data.width); view.setBottom(view.getTop() + data.height); view.setTextColor(data.textColor); int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); }
final ScrollView scrollView = (ScrollView) findViewById(R.id.consoleTab); TextView textView = (TextView) findViewById(R.id.consoleView); boolean autoScroll = (textView.getBottom() - (scrollView.getHeight() + scrollView.getScrollY())) <= 0; textView.setText(state.getConsole().getText()); if (autoScroll) { scrollView.post(new Runnable() { public void run() { scrollView.fullScroll(ScrollView.FOCUS_DOWN); } }); }
int heightDiff = newHeight - oldHeight; textView.layout(textView.getLeft() - widthDiff / 2, textView.getTop() - heightDiff / 2, textView.getRight() + widthDiff / 2, textView.getBottom() + heightDiff / 2);
private boolean checkMargin() { if (!rectFAll.contains(localRectF2)) { return false; } for (TextView textView : tvs) { if (!rectFAll.contains(textView.getLeft(), textView.getTop(), textView.getRight(), textView.getBottom())) { return false; } } return true; }
public void onClick(float y) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { TextView textView = (TextView) getChildAt(i); if (textView.getBottom() >= y) { if (i == 0) { return; } textView.setSelected(!textView.isSelected()); textView.setBackgroundColor(textView.isSelected() ? callback.getTableLayout().getBackgroundColorSelected() : Color.TRANSPARENT); textView.setTextColor(textView.isSelected() ? callback.getTableLayout().getTableTextColorSelected() : callback.getTableLayout().getTableTextColor()); return; } } }
@Test @FlakyTest(tolerance = TOLERANCE) public void testAlignItems_baseline_wrapReverse() throws Throwable { final FlexboxTestActivity activity = mActivityRule.getActivity(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { activity.setContentView(R.layout.activity_align_items_baseline_test); FlexboxLayout flexboxLayout = (FlexboxLayout) activity .findViewById(R.id.flexbox_layout); flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); TextView textView1 = (TextView) activity.findViewById(R.id.text1); TextView textView2 = (TextView) activity.findViewById(R.id.text2); TextView textView3 = (TextView) activity.findViewById(R.id.text3); int bottomPluBaseline1 = textView1.getBottom() + textView1.getBaseline(); int bottomPluBaseline2 = textView2.getBottom() + textView2.getBaseline(); int bottomPluBaseline3 = textView3.getBottom() + textView3.getBaseline(); assertThat(bottomPluBaseline1, is(bottomPluBaseline2)); assertThat(bottomPluBaseline2, is(bottomPluBaseline3)); }
@Test @FlakyTest(tolerance = TOLERANCE) public void testAlignContent_flexEnd() throws Throwable { final FlexboxTestActivity activity = mActivityRule.getActivity(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { activity.setContentView(R.layout.activity_align_content_test); FlexboxLayout flexboxLayout = (FlexboxLayout) activity .findViewById(R.id.flexbox_layout); flexboxLayout.setAlignContent(FlexboxLayout.ALIGN_CONTENT_FLEX_END); } }); FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout); assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_FLEX_END)); onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout))); onView(withId(R.id.text3)).check(isBottomAlignedWith(withId(R.id.flexbox_layout))); onView(withId(R.id.text1)).check(isAbove(withId(R.id.text3))); onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout))); onView(withId(R.id.text2)).check(isAbove(withId(R.id.text3))); TextView textView1 = (TextView) activity.findViewById(R.id.text1); TextView textView3 = (TextView) activity.findViewById(R.id.text3); assertThat(textView1.getBottom(), is(flexboxLayout.getBottom() - textView3.getHeight())); }