Android 在图像动画之后,动态布局和我现有布局中的按钮

Android 在图像动画之后,动态布局和我现有布局中的按钮,android,android-layout,Android,Android Layout,在图像动画之后,我尝试在现有布局中加载我的动态布局和按钮。实际上,我的图像必须从屏幕的中心移动到顶部。之后,我的动态布局与按钮一样,可见下面的图像。但我的动态布局和按钮不可见 活动\u main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/Line

在图像动画之后,我尝试在现有布局中加载我的动态布局和按钮。实际上,我的图像必须从屏幕的中心移动到顶部。之后,我的动态布局与按钮一样,可见下面的图像。但我的动态布局和按钮不可见

活动\u main.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bgm2"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="132dp"
    android:layout_marginLeft="20dp"
    android:src="@drawable/jpa2" />

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_marginLeft="110dp"
    android:max="100"/>
<?xml version="1.0" encoding="utf-8"?>

translate.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bgm2"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="132dp"
    android:layout_marginLeft="20dp"
    android:src="@drawable/jpa2" />

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_marginLeft="110dp"
    android:max="100"/>
<?xml version="1.0" encoding="utf-8"?>


MainActivity.java

    public class MainActivity extends Activity {

ProgressBar probar;
int progress=0;
Handler h = new Handler();
ImageView logoview;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main); 
    logoview=(ImageView) findViewById(R.id.imageView1);
    probar=(ProgressBar) findViewById(R.id.progressBar1);
    new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub


            while(progress <100){
                progress+=10;

                h.post(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        probar.setProgress(progress);
                    }
                });
                try {

                    Thread.sleep(1000);
                    probar.setVisibility(1500);

                } catch (Exception e) {
                    // TODO: handle exception
                }

            }   


        }


    }).start();


    logoview =(ImageView) findViewById(R.id.imageView1);
    Animation animation =AnimationUtils.loadAnimation(MainActivity.this, R.animator.translate);
    animation.setFillAfter(true);
    logoview.startAnimation(animation);

    LinearLayout ll =new LinearLayout(this);
    ll=(LinearLayout) findViewById(R.id.LinearLayout1);
    LinearLayout hl =new LinearLayout(this);
    hl.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    hl.setLayoutParams(lp);
    hl.setVisibility(View.VISIBLE);
    ll.addView(hl);


    Button bigdata =new Button(this);
    bigdata.setBackgroundResource(R.drawable.data);
    hl.addView(bigdata);

    Button cloud = new Button(this);
    cloud.setBackgroundResource(R.drawable.cloud);
    hl.addView(cloud);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
公共类MainActivity扩展活动{
ProgressBar-probar;
int progress=0;
Handler h=新的Handler();
图像视图logoview;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(窗口。功能\u无\u标题);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_全屏,
WindowManager.LayoutParams.FLAG(全屏);
setContentView(R.layout.activity_main);
logoview=(ImageView)findViewById(R.id.imageView1);
probar=(ProgressBar)findViewById(R.id.progressBar1);
新线程(newrunnable()){
@凌驾
公开募捐{
//TODO自动生成的方法存根

while(progress将平移动画替换为以下内容:

<translate
android:fromYDelta="50%p"
android:toYDelta="0%p"
android:duration="3000"
/>

将“平移”动画替换为以下内容:

<translate
android:fromYDelta="50%p"
android:toYDelta="0%p"
android:duration="3000"
/>

布局现在可见,但我的想法是在动画完成后加载布局和按钮。现在布局和按钮在动画之前加载。布局现在可见,但我的想法是在动画完成后加载布局和按钮。现在布局和按钮在动画之前加载。