0

`

Hi,

I have requirement of using my own background and blue light for toggle button.

However, using this i am not able to custom position light of toggle button which is always placed to the bottom of button.

I want to move it above and just below center of button.

I tried with paddingBottom but that did not help. Any help regarding this appreciated.

-Thanks, Manju

Manju
  • 677
  • 5
  • 13
  • 27

3 Answers3

1

That light is part of the nine-patch png. If you create new backgrounds, you need to add your own "on" and "off" circles to the file. You then use the border lines of the nine-patch to prevent stretching of the circle.

http://developer.android.com/guide/developing/tools/draw9patch.html

Read also my answer here for another explanation: How to create android spinner without down triangle on the right side of the widget

Community
  • 1
  • 1
Aleadam
  • 40,203
  • 9
  • 86
  • 108
  • Hi Aleadam, thanks for your response. I have added my own nine-patch file for light on/off, but this light is placed at the bottom of toggle button and it is hardly 8 pixels above from the bottom of button. I want to move this light above with at least 20 pixels. I tried using android:paddingBottom for ToggleButton but that did not move the light even by 1pixel up. Is there any option to move this ? – Manju May 25 '11 at 11:16
1

Use a LayerList and position the graphic on the toggle button by enclosing the drawable in a bitmap tag, and set its gravity to 'center' - see LayerList here

John J Smith
  • 11,435
  • 9
  • 53
  • 72
0

Use a relativeLayout and do android:layout_Below, if I understand your question correctly

Andrew
  • 830
  • 3
  • 10
  • 27