Is ProgressBar correctly handling padding-values?

by Cyril M » Thu, 05 Mar 2009 01:04:43 GMT

Sponsored Links
 ere is a skeleton of the class I'm currently working on.
Unfortunatly, i'm stuck on two problems and it's driving me mad !

The first problem is about the onKeyDown(KeyEvent) : I don't
understand why this method isn't called while I pressed a key on the
The second problem deals with padding. Indeed, I'm always creating
widget using fake paddings in order to be sure my widget correctly
handle those values. Unfortunatly, I tried to extend a ProgressBar and
I had some problems because my ProgressBar is clipped.

My code is :


import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.ProgressBar;

public class ProgressWheel extends ProgressBar {

private static final String TAG_LOG = "ProgressWheel";
private static final Paint mPaint = new Paint();

private float oldX;

public ProgressWheel(Context context, AttributeSet attrs) {
this(context, attrs, 0);

public ProgressWheel(Context context, AttributeSet attrs, int
defStyle) {
super(context, attrs, defStyle);


setPadding(5, 15, 40, 10)


protected synchronized void onDraw(Canvas canvas) {
* I'm not sure the onDraw(Canvas) method from ProgressBar is
* implemented. Indeed. With padding values, The progressBar
may be
canvas.drawRect(0, 0, getWidth()-1, getHeight()-1, mPaint);

public boolean onKeyDown(int keyCode, KeyEvent event) {
* I don't understand why this method is not called
int progress = getProgress();
Log.d(TAG_LOG, "onKeyDown");
switch (keyCode) {
if (progress <= 0) break;
setProgress(progress - 1);
return true;

if (progress >= getMax()) break;
setProgress(progress + 1);
return true;

return super.onKeyDown(keyCode, event);

public boolean onTouchEvent(MotionEvent event) {
Log.d(TAG_LOG, "onTouchEvent");
int progress = getProgress();

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
oldX = event.getX();
case MotionEvent.ACTION_MOVE:
if (event.getX() > oldX) {
setProgress(progress + 1);
else setProgress(progress -

Is ProgressBar correctly handling padding-values?

by Sundog » Thu, 05 Mar 2009 01:52:47 GMT

 > Sorry for being terse, sent from my phone :)

Yeah, isn't that keyboard a drag?  ;)

Sponsored Links

Is ProgressBar correctly handling padding-values?

by Cyril Mottier » Thu, 05 Mar 2009 17:01:11 GMT

  prefer you being terse and giving understandable answers than no one
answering me :p. Thanks ;)

On 4 mar, 18:09, Romain Guy <> wrote:

Other Threads

1. jar.libs.dir is the new external.libs.dir?

I upgraded to ADT 8 and my projects wouldn't build with Ant any more , 
failing with a lot of class not found errors. 
I have a file with the following contents:


A quick grep for the rules files shows that 'external.libs.dir' is not used 
any more. It seems it 
has been replaced by 'jar.libs.dir'. This doesn't seem to be documented 
anywhere, so are we supposed 
to use 'jar.libs.dir' from now on? If so, a simple

<property name="external.libs.dir" value="${jar.libs.dir}" />

or something would be nice, so that people's builds don't break all of a 


2. Regarding emulator.exe has encountered a problem and needs to close. We are sorry for the inconvenience.

Hello Everybody,
                 I am stuck with the above mentioned bug while
running emulator. Suggest me solution for this problem
   The bug details are as follows:

emulator.exe has encountered a problem and needs to close.  We are
sorry for the inconvenience.

AppName: emulator.exe    AppVer:         ModName: emulator.exe
ModVer:  Offset: 0015cde3

System Configuration(Information):

Operating System ----Windows XP  with service pack 2


Processor ---Intel(R) Xenon(TM) CPU  2.4GHz

Graphics card---Intel(R) 82945G Express Chipset Family

Suggest the possible ways.


3. Completely disable Soft Keyboard from EditText

4. what is Third party application server??

5. Intriguing focus problem with PreferenceActivity

6. How do I interact with different music player?

7. SQLite & multithreads