Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd black border to button dynamically
    primarykey
    data
    text
    <p>here i want to add a black color border dynamically b/w each button . </p> <p><strong>As you can see the gray button , they are getting mixed because of same color. I want a black line or any thing b/w each button. So I can differentiate it.</strong> </p> <p><img src="https://i.stack.imgur.com/NBJQH.png" alt="enter image description here"></p> <p>Hope you have understood my problem.?</p> <p>Following is the code </p> <pre><code> int i = 1; int nLeftStartPnt = 18; int nTopStartPnt = 0; int nMarkerHeight = 28; int nMarkerVwActualWidth = 780; int nMarkerWidth = 50; int nlen = 10; int nsetPaddingTop = 123; int nsetPaddingLeft = 0; FrameLayout layout = (FrameLayout) findViewById(R.id.MarkerLinearlayout); for(i = 1; i &lt; nlen ; i++) { Button bMarkerBtn = new Button(this); layout.addView(bMarkerBtn); bMarkerBtn.setId(i); bMarkerBtn.setX(nsetPaddingLeft + i); //bMarkerBtn.setTop(nsetPaddingTop); bMarkerBtn.setWidth(nMarkerWidth); bMarkerBtn.setHeight(nMarkerHeight); // bMarkerBtn.getTotalPaddingLeft() // bMarkerBtn.setPadding(2,0, 0, 0); if(i == 0) { bMarkerBtn.setBackgroundColor(Color.DKGRAY); } if(i == 1) { bMarkerBtn.setBackgroundColor(Color.BLUE); } if(i == 2) { bMarkerBtn.setBackgroundColor(Color.RED); } if(i == 3) { bMarkerBtn.setBackgroundColor(Color.GREEN); } if(i == 4) { bMarkerBtn.setBackgroundColor(Color.BLUE); } if(i == 5) { bMarkerBtn.setBackgroundColor(Color.YELLOW); } if(i == 6) { bMarkerBtn.setBackgroundColor(Color.GRAY); } if(i == 7) { bMarkerBtn.setBackgroundColor(Color.GRAY); } if(i == 8) { bMarkerBtn.setBackgroundColor(Color.GRAY); } if(i == 9) { bMarkerBtn.setBackgroundColor(Color.GRAY); } if(i == 10) { bMarkerBtn.setBackgroundColor(Color.GRAY); } nsetPaddingLeft = nsetPaddingLeft + nMarkerWidth +1; // Log.d("Button Click","Clicked ON "+ Integer.toString(i)); bMarkerBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Log.d("Button Click","Clicked ON "+ Integer.toString(view.getId())); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload