i am new to android studio,
I am trying to create a FrameLayout of specific size at certain location inside another framelayout dynamically. here is my following code,
FrameLayout parentLayout = (FrameLayout)findViewById(R.id.tile_container);
FrameLayout framelayout = new FrameLayout(this);
framelayout.setBackgroundColor(0x0000FF);
framelayout.setLayoutParams(new LinearLayout.LayoutParams(100,100);
framelayout.SetX(50)
framelayout.SetY(50)
parentLayout.addView(framelayout);
but i am not getting any layout generated can anyone please help me
When a 32-bit hex value is specified, the two characters corresponding to the colors specify the 8-bit alpha transparency value. This value varies between 00 (completely transparent) and FF (completely opaque).
Hexadecimal colors when used directly through an int
, must be AARRGGBB. Its hexadecimal color does not specify alpha,
then it is being automatically set to 00.
To set a color to 100% opacity, add FF at the start.
Your code should look like this:
FrameLayout parentLayout = findViewById(R.id.tile_container);
FrameLayout framelayout = new FrameLayout(this);
framelayout.setBackgroundColor(0xFF0000FF);
framelayout.setLayoutParams(new FrameLayout.LayoutParams(100,100);
framelayout.SetX(50)
framelayout.SetY(50)
parentLayout.addView(framelayout);
Alternatively you can use Color.BLUE
I hope this helps. ^-^