Weird Button src Problem

Put your problem here if it does not fit any of the other categories.

Weird Button src Problem

Postby ramgraph1 » Wed Jan 30, 2008 8:23 am

Using the following code in a relative layout I get only one of the buttons showing the drawable - the others all end up with the standard button graphic at 50 by 50 dip! If I change "src" to "background", three of the buttons end up displaying the desired graphic with two still with the default button. Any ideas what's going on here? Thanks.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <Button
  2.  
  3. id="@+id/button3"
  4.  
  5. android:layout_width="50dip"
  6.  
  7. android:layout_height="50dip" android:padding="4dip"
  8.  
  9. android:layout_below="@+id/topbutton"
  10.  
  11. android:layout_centerHorizontal="true"
  12.  
  13. android:src="@drawable/mainbutton">
  14.  
  15. </Button>
  16.  
  17. <Button
  18.  
  19. id="@+id/button2"
  20.  
  21. android:layout_width="50dip"
  22.  
  23. android:layout_height="50dip" android:padding="4dip"
  24.  
  25. android:layout_below="@+id/topbutton"
  26.  
  27. android:layout_toLeft="@+id/button3"
  28.  
  29. android:src="@drawable/mainbutton">
  30.  
  31. </Button>
  32.  
  33. <Button
  34.  
  35. id="@+id/button1"
  36.  
  37. android:layout_width="50dip"
  38.  
  39. android:layout_height="50dip" android:padding="4dip"
  40.  
  41. android:layout_below="@+id/topbutton"
  42.  
  43. android:layout_toLeft="@+id/button2"
  44.  
  45. android:src="@drawable/mainbutton">
  46.  
  47. </Button>
  48.  
  49. <Button
  50.  
  51. id="@+id/button4"
  52.  
  53. android:layout_width="50dip"
  54.  
  55. android:layout_height="50dip" android:padding="4dip"
  56.  
  57. android:layout_below="@+id/topbutton"
  58.  
  59. android:layout_toRight="@+id/button3"
  60.  
  61. android:src="@drawable/mainbutton">
  62.  
  63. </Button>
  64.  
  65. <Button
  66.  
  67. id="@+id/button5"
  68.  
  69. android:layout_width="50dip"
  70.  
  71. android:layout_height="50dip" android:padding="4dip"
  72.  
  73. android:layout_below="@+id/topbutton"
  74.  
  75. android:layout_toRight="@+id/button4"
  76.  
  77. android:src="@drawable/mainbutton">
  78.  
  79. </Button>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Top

Postby plusminus » Wed Jan 30, 2008 11:06 am

Hello ramgraph,

hm, your behaviour is really weird. (with me it shows no image at all)

But normally you would use ImageButtons for such things :!: because the normal Button is not 100% capable (or not at all) of displaying images...
With the ImageButtons it works fine.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby ramgraph1 » Wed Jan 30, 2008 1:09 pm

Hmm. Thanks for your reply. I changed from ImageButton to Button because I had a padding on the buttons and with ImageButton it was giving me the button's graphic as a frame around my graphic, which I didn't want. With padding off ImageButton does work fine, but now I need to use a different way to lay the pictures out with space between them...
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby ramgraph1 » Fri Feb 01, 2008 1:31 pm

The solution I have chosen for solving my layout problem is placing a TextView between the buttons with the text set to blank (text=""). This produces the layout I desire but is it a poor way of handling the issue? If someone is thinking, "Yeah, dummy - you should be doing this...!" Please think out loud here so that I may be enlightened!
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests