0

I have just started android. I made an 8x8 grid for chess game, and made the buttons for it. I am trying to give a background color for my buttons, my buttons have 40dp width and 60dp height. The problem is, when I put a background color, it takes almost 43dp width and 63dp height which creates a problem of overlapping the buttons.

PS: I tried backgroundTint, but it does not show any color on my device as I'm using 4.2.2 jellyBean.

see the image below:

enter image description here

thor
  • 21,418
  • 31
  • 87
  • 173
Mehran Khan
  • 80
  • 1
  • 10
  • What type of background you're using. Are you use just color for background or any drawable? Sometimes you can use Image button instead of a button. it will solve you problem. – Kathi Apr 02 '16 at 08:30
  • thank you for your response. i am using just color for background. you can see the image i have given a link. the first row has just background color and all the other rows has backgroundTint. – Mehran Khan Apr 02 '16 at 08:33
  • @Mehran Khan show some code – Keyur Lakhani Apr 02 '16 at 08:36
  • as i have 64 buttons it could be weird to post here 64 buttons code, here is two kind of codes. one is with just background and the other one is backgroundTint. – Mehran Khan Apr 02 '16 at 08:40
  • @KeyurLakhani I'm sorry for in convenient, i have just joined the StackOverflow. i don't know how to post code and images in a good way. please try to understand. thank you – Mehran Khan Apr 02 '16 at 08:42
  • I think you are trying in wrong way you have to create one view and maintain ondraw of that for chess app and you should use some github examples for better understanding http://stackoverflow.com/questions/15207421/designing-chess-user-interface-in-android – Keyur Lakhani Apr 02 '16 at 08:51
  • @KeyurLakhani thank you for help. as i am a student, i am restricted by the teacher to make this game in such a way that i am using. but i don't know how to draw my board. – Mehran Khan Apr 02 '16 at 09:05

1 Answers1

0

You are using sp instead of dp. Just try this code.

     <Button android:layout_width="40dp"
 android:layout_height="60dp"
 android:id="@+id/a1"
 android:onClick="aOne" 
android:background="#000000" /> 
Darish
  • 11,032
  • 5
  • 50
  • 70
  • Thanks to all for useful tips.. what i did, i used ImageButton instead of Button and adjusted the width and height of the ImageButton(s), that solved the problem. – Mehran Khan Apr 02 '16 at 10:29