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

  • Home
  • SEARCH
  • 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 9071771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:59:48+00:00 2026-06-16T17:59:48+00:00

I’m creating a bar graph like structure using buttons and textviews. I want to

  • 0

I’m creating a bar graph like structure using buttons and textviews.

I want to display some specific value above each bar.

If the value is within 4 digits, it gets displayed properly but as soon as 5 digit no. comes, text gets wrapped as shown in below screenshot.

I eaven tried android:singleLine="true", but that doesn’t change anything.

screen-shot

layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <SeekBar
        android:id="@+id/seekBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:maxHeight="9dp"
        android:minHeight="9dp"
        android:padding="10dp"
        android:max="100"
        android:progressDrawable="@drawable/seekbar_progress"
        android:thumb="@drawable/shine_btn" />

    <TextView
        android:id="@+id/tvValue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
        android:layout_alignRight="@id/seekBar"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="30dp" />

    <LinearLayout
        android:id="@+id/Graph01"
        android:layout_width="wrap_content"
        android:layout_height="200dp"
        android:layout_below="@id/seekBar"
        android:layout_marginTop="50dp"
        android:gravity="bottom"
        android:orientation="vertical"
        android:weightSum="1" >

        <com.example.calci.views.MyTextView
            android:id="@+id/tvGraph01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp" />        
        <Button
            android:id="@+id/btnGraph01"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="0.1"                        
            android:background="#99f" />                
    </LinearLayout>


    <LinearLayout
        android:id="@+id/Graph02"
        android:layout_width="wrap_content"
        android:layout_height="200dp"
        android:layout_below="@id/seekBar"
        android:layout_marginTop="50dp"
        android:layout_toRightOf="@id/Graph01"
        android:gravity="bottom"
        android:orientation="vertical"
        android:weightSum="1" >

        <com.example.calci.views.MyTextView
            android:id="@+id/tvGraph02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp" />

        <Button
            android:id="@+id/btnGraph02"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="0.1"
            android:background="#9f9" />
    </LinearLayout>

<!-- AND SO ON... -->
<RelativeLayout />

activity:

seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromTouch) {
lp = new LinearLayout.LayoutParams(new ViewGroup.MarginLayoutParams(20,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    lp.setMargins(55, 0, 0, 0);
    tvGraph01.setLayoutParams(lp);
    tvGraph01.setTextSize(6);
    tvGraph01.setGravity(Gravity.CENTER);

    lp = new LinearLayout.LayoutParams(new ViewGroup.MarginLayoutParams(20,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    lp.setMargins(2, 0, 0, 0);
    tvGraph02.setLayoutParams(lp);
    tvGraph02.setTextSize(6);
    tvGraph02.setGravity(Gravity.CENTER);

lp = new LinearLayout.LayoutParams(20, 0, 0.0002f * 2 * progress * 20);
    lp.setMargins(55, 0, 0, 0);
    btnGraph01.setLayoutParams(lp);

    lp = new LinearLayout.LayoutParams(20, 0, 0.0002f * 2 * progress * 15);
    lp.setMargins(2, 0, 0, 0);
    btnGraph02.setLayoutParams(lp);
               }
    });

MyTextView

public class MyTextView extends TextView {
@Override
    protected void onDraw(Canvas canvas) {
        canvas.save();
// RORARING the textbox as I want to show text at right angle.
        canvas.rotate(270, getWidth() / 2, getHeight() / 2);
        super.onDraw(canvas);
        canvas.restore();
    }
}

I guess prime reason behind this is setting height of the textview as 20.
I tried increasing the height of textview, but that increases the space between buttons.
I tried various values of gravity, but that also don’t work.

ANY HELP APPRECIATED…

EDIT

1). Anything from .android:singleLine="true" or android:ellipsize="end" or android:maxLines="1"wont work for my cause as I don’t want to put … for text wrapping.
I want to display the full text.

2). Setting android:layout_height="300dp" to LinearLayout didn’t made any difference apart from increase in height of all buttons.

3). Setting android:layout_height="150dp" to TextView didn’t made any difference as I’m setting height and width in code.

  • 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-16T17:59:49+00:00Added an answer on June 16, 2026 at 5:59 pm

    One important change which was required : changing android:layout_toRightOf="@id/Graph01 in LinearLayout with id Graph02 to android:layout_toRightOf="@id/tvGraph01"

    i.e. even if textview width increases, corresponding linearlayout won’t be affected.

    Also, I have to set margins for tvGraph02,btnGraph02,etc. after increasing width of textview in code.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
i want to parse a xhtml file and display in UITableView. what is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am using JSon response to parse title,date content and thumbnail images and place
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

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.