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 7882923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:24:00+00:00 2026-06-03T04:24:00+00:00

I am working on a app where I want to show a quantity in

  • 0

I am working on a app where I want to show a quantity in a rectangle. The following is what I need. I have 2 values, say totalMoney and spentMoney.
I want to show the remaining money (i.e. totalMoney – spentMoney) in a rectangle box in 2 colors.

Like this:

|======================| 
|///////////|          |
|////50%////|          |   
|///////////|          |
|======================|

This rectangle will be in a custom View, in collaboration with other components like textview etc.

How do I get this in Android? I am working on Android 2.2.

  • 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-03T04:24:01+00:00Added an answer on June 3, 2026 at 4:24 am

    You need a ProgressBar.

    Here is an example of a custom one.

        <ProgressBar style="?android:attr/progressBarStyleHorizontal"
          android:layout_width="fill_parent"
       android:layout_height="7dip"
      android:id="@+id/pop1000Bar"
      android:max="1000"
      android:progress="500"
      android:progressDrawable="@drawable/progressbarlayers"
      >
      </ProgressBar>
    

    progressbarlayers is an xml file that defines how I want the progress bar to look. Here is how mine is set up.

    <?xml version="1.0" encoding="UTF-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                    android:startColor="#ff9d9e9d"
                    android:centerColor="#ff5a5d5a"
                    android:centerY="0.75"
                    android:endColor="#ff747674"
                    android:angle="270"
            />
        </shape>
    </item>
    
    <item
        android:id="@android:id/progress"
    >
        <clip>
            <shape>
                <corners
                    android:radius="5dip" />
                <gradient
                    android:startColor="#A9F505"
                    android:endColor="#FFF700"
                    android:angle="270" />
            </shape>
        </clip>
    </item>
    
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
            <size android:height="3dip"/>
    
    
    
                <gradient
                        android:startColor="#80ffd300"
                        android:centerColor="#80ffb600"
                        android:centerY="0.75"
                        android:endColor="#a0ffcb00"
                        android:angle="270"
                />
            </shape>
        </clip>
    </item>
    <item
        android:id="@android:id/progress"
    >
        <clip>
            <shape>
                <corners
                    android:radius="5dip" />
                <gradient
                    android:startColor="#A9F505"
                    android:endColor="#FFF700"
                    android:angle="270" />
            </shape>
        </clip>
    </item>
    
    </layer-list>
    

    It comes out looking like this:

    enter image description here

    But you can make it look like whatever you need it to.

    EDIT: There are many ways you could achieve getting text on to them. If your parent layout is a RelativeLayout you can just stack a TextView on top of the progress bar and call setText on the text view each time the progress is updated. Probably what is a better approach is subclass ProgressBar to draw it on there for you. Here is an example of that. They just made a new View that extends ProgressBar, and override the onDraw to draw some text to the canvas each time as well as painting the bars and background.

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

Sidebar

Related Questions

So I have been working with an app where I need to show the
I have been working on a conference related app. I want to show ringing
I'm working on an iphone app and want to have a page showing multiple
I'm working on an app in CodeIgniter, and I want to have admin pages
I have an android app and I want to show japanese kanji on it,
I am working on a Mapkit App and I want to show annotations according
I'm working on windows 8 metro style app. I want to show a save
I am working on an iPad app. I have a viewcontroller which I want
I am working on an app where I want to show an NSMenu context
I am working on a view based app in iphone, i want to show

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.