Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8444389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:23:25+00:00 2026-06-10T09:23:25+00:00

I have a TextView inside a ScrollView, the TextView is filled with a large

  • 0

I have a TextView inside a ScrollView, the TextView is filled with a large text which only some part of its text is visible on screen at anytime.
Now I want to (programmatically) force some part of the text to be visible for user. for example, my text is:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut id ante tellus. Nulla facilisi. Sed gravida fringilla velit, non sollicitudin tellus egestas non. Cras congue, nulla id bibendum tempus, dui dui blandit elit, elementum dictum dolor eros et mi. Nullam leo tellus, aliquet vel tincidunt sed, suscipit nec dui. Nunc dapibus, odio vestibulum hendrerit vestibulum, lorem orci dictum arcu, quis porttitor lorem libero sit amet odio. Sed imperdiet viverra diam, eu porttitor ipsum fringilla et. Suspendisse consectetur sapien ac felis tincidunt dictum. Suspendisse ultrices porta dignissim. Maecenas in nibh sed nisi facilisis dignissim non ut tortor. Pellentesque eleifend tempus sem, sit amet mattis arcu auctor id. Vivamus at tortor rutrum diam vestibulum adipiscing. Suspendisse potenti. Integer sollicitudin laoreet enim ac suscipit. Quisque convallis facilisis pharetra.

I want to force the bold word (tortor in this example) to be visible to the user (maybe by scrolling the textview vertically with a correct value).
Is there any way to do this?

EDIT: I don’t want to make the word bold! question updated to clarify my request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:23:26+00:00Added an answer on June 10, 2026 at 9:23 am

    Here is one way to scroll to a particular word:

    public void scrollToWord(String string) {
        TextView textView = (TextView) findViewById(R.id.text1);
        String text = textView.getText().toString();
    
        // Find the first occurrence of the word 
        int position = text.indexOf(string);
        // Calculate how far in the word is: 30%, 40%, 73% 
        int percent = (int) (position / (double) text.length() * 100);
        // Calculate how far to scroll
        int y = textView.getHeight() * percent;
    
        // Finally scroll
        ((ScrollView) textView.getParent()).scrollTo(0, y);
    }
    

    I have two notes on this:

    1. This only scrolls to the first occurrence, but it is easy enough to change to String.indexOf(string, start) and find the second, third, etc.

    2. If you want to scroll to this position as soon as the app has started, you must wait until after onResume() has finished. But there is no method for this… I suggest using a Handler and I can help you with that if you need it.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a some ui widgets including textview inside RelativeLayout which is clickable. My
I have a TextView which i set the text using setText(). In properties, I
I have a UIScrollView, inside which I have some UILabels and a UITextView. The
i have a textview and imageview inside a linearlayout. textview containes more text so
I have different table rows, each of it contains some information text which should
I have a Listview inside a Scrollview and manually binding its data on the
I have a programmatically generated ScrollView with a TextView inside of it. I wish
I've created a ScrollView with a RelativeLayout inside of it. I have a TextView
I've a problem I can't solve: inside a ScrollView I only have a LinearLayout.
I have a TextView which I fill with text from a string resources in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.