|
|
发表于
2023-8-19 10:39:06
来自手机
|
显示全部楼层
来自 上海
Java源代码:- final LinearLayout lin = new LinearLayout(getApplicationContext());
- LinearLayout.LayoutParams ly = new LinearLayout.LayoutParams(-1,-1);
- lin.setGravity(Gravity.BOTTOM|Gravity.CENTER);
- lin.setOrientation(1);
- lin.setPadding(80,0,80,160);
- LinearLayout lin2 = new LinearLayout(getApplicationContext());
- LinearLayout.LayoutParams lin2ly = new LinearLayout.LayoutParams(-2,-2);
- lin2.setPadding(20,0,20,0);
- GradientDrawable g = new GradientDrawable();
- g.setColor(Color.parseColor("#FFDBC29A"));
- g.setCornerRadius(20);
- lin2.setBackground(g);
- lin.addView(lin2,lin2ly);
- Button b = new Button(getApplicationContext());
- b.setText("哈哈哈哈好");
- b.setTextColor(Color.parseColor("#EA000000"));
- b.setTextSize(16);
- b.setBackground(new ColorDrawable(255));
- LinearLayout.LayoutParams bl = new LinearLayout.LayoutParams(-2,-2);
- b.setLayoutParams(bl);
- lin2.addView(b,bl);
- lin2.setOrientation(1);
- addContentView(lin,ly);
- TranslateAnimation tr = new TranslateAnimation(0,0,100,0);
- final AlphaAnimation al = new AlphaAnimation(0,1);
- al.setDuration(500);
- tr.setDuration(500);
- lin.setAnimation(tr);
- new Thread(new Runnable(){
- @Override
- public void run() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {}
- runOnUiThread(new Runnable(){
- @Override
- public void run() {
- lin.removeAllViews();
- }
- });
- }
- }).start();
复制代码 |
|