Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addToUI(final Context con) {
- myactivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- MainFrame main = new MainFrame(con);
- main.backgroundColor(0, 82, 255, 0.5);
- MainFrame test = new MainFrame(con);
- test.backgroundColor(215, 255, 4, 1);
- test.parameters.height = 100;
- main.addView(test,test.parameters);
- myactivity.addContentView(main, main.parameters);
- }
- }
- }
- public class MainFrame extends FrameLayout {
- public FrameLayout.LayoutParams parameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
- public MainFrame(Context con) {
- this(con, null);
- }
- public MainFrame(Context context, AttributeSet attrs){
- this(context, attrs, 0);
- }
- public MainFrame(Context context, AttributeSet attrs, int defStyle){
- super(context, attrs, defStyle);
- }
- //This seams to keep have the same opacity as the parent
- public void backgroundColor(int red, int green, int blue, double alphaa) {
- this.setBackgroundColor(Color.rgb(red, green, blue));
- final AlphaAnimation alpha = new AlphaAnimation((float)alphaa, (float)alphaa);
- alpha.setDuration(0);
- alpha.setFillAfter(true);
- this.startAnimation(alpha);
- //this.animate().alpha((float)alphaa).setDuration(0).start();
- }
- public void backgroundColor(int red, int green, int blue) {
- this.setBackgroundColor(Color.rgb(red, green, blue));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement