2016-01-02 2 views
1

У меня есть 4 макета в одном действии и макет работает правильно. Я хочу, когда я проверяю флажок, а затем его скрытый 3-й макет и 4-й макет сползает и заменяет 3-й макет, а когда снят флажок, а затем 3-й макет отображает 4-е слайд вниз и устанавливает правильную позицию.Анимация не работает в действии

, но он не работает должным образом ...

MyCode

checklayout =(RelativeLayout)findViewById(R.id.layout_check); 
    promolayout =(RelativeLayout)findViewById(R.id.promo_layout); 
    _Payment_full=(RelativeLayout)findViewById(R.id.pay_full); 
     _CheckBox = (CheckBox) findViewById(R.id.check_wallet); 
     _CheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 
      @Override 
      public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { 
       if (isChecked == true) { 
        promolayout.setVisibility(View.GONE); 
        _Payment_full.startAnimation(slide_up); 
        _Payment_full.animate() 
          .translationYBy(100) 
          .translationY(0) 
          .setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); 
        String url = "http://www.example.com/index.php"; 
        StringRequest postRequest = new StringRequest(Request.Method.POST, url, 
          new Response.Listener<String>() { 
           @Override 
           public void onResponse(String response) { 

            try { 

             JSONObject json_Response = new JSONObject(response); 
             String _RchAmount = json_Response.getString("pay_from_wallet"); 
             String _Remainbalance = json_Response.getString("ewalletbalance"); 
             String _InrPay = json_Response.getString("amt_collected"); 
             confirm_payWallet.setText("Pay from Yup Wallet Rs. " + _RchAmount); 
             confirm_TotalWallet.setText("Your current wallet balance is Rs." + _Remainbalance); 
             total_pay.setText("Rs. " + _InrPay); 
            } catch (JSONException e) { 
             e.printStackTrace(); 
            } 
            Log.d("checked in wallet", "------>" + response); 
           } 
          }, 
          new Response.ErrorListener() { 
           public void onErrorResponse(VolleyError error) { 
            Log.e("Checked err error==", "===>" + error); 
            error.printStackTrace(); 
           } 
          }) { 

         protected Map<String, String> getParams() { 
          MyApplication uid = (MyApplication) getApplicationContext(); 
          String user = uid.getuser(); 
          MyApplication _tansId = (MyApplication) getApplicationContext(); 
          String trans_id = _tansId.getTransaction(); 
          Map<String, String> params = new HashMap<>(); 
          params.put("akey", "XXXXXX"); 
          params.put("userid", user); 
          params.put("transid", trans_id); 
          params.put("ewallet_checkbox", "on"); 

          Log.i(TAG, "Sending Value" + params); 
          return params; 
         } 
        }; 
        newApp.getInstance().addToRequestQueue(postRequest); 
        } 
       else 
       { 
        promolayout.setVisibility(View.VISIBLE); 
        _Payment_full.startAnimation(slide_down); 
        _Payment_full.animate() 
         .translationYBy(0) 
         .translationY(100) 
         .setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); 
        String url = "http://www.example.com/index.php"; 
        StringRequest postRequest = new StringRequest(Request.Method.POST, url, 
          new Response.Listener<String>() { 
           @Override 
           public void onResponse(String response) { 

            try { 

             JSONObject json_Response = new JSONObject(response); 
             String _RchAmount = json_Response.getString("pay_from_wallet"); 
             String _Remainbalance = json_Response.getString("ewalletbalance"); 
             String _InrPay = json_Response.getString("amt_collected"); 
             confirm_payWallet.setText("Pay from Yup Wallet Rs. " + _RchAmount); 
             confirm_TotalWallet.setText("Your current wallet balance is Rs." + _Remainbalance); 
             total_pay.setText("Rs. " + _InrPay); 
            } catch (JSONException e) { 
             e.printStackTrace(); 
            } 
            Log.d("checked in wallet", "------>" + response); 
           } 
          }, 
          new Response.ErrorListener() { 
           public void onErrorResponse(VolleyError error) { 
            Log.e("Checked err error==", "===>" + error); 
            error.printStackTrace(); 
           } 
          }) { 

         protected Map<String, String> getParams() { 
          MyApplication uid = (MyApplication) getApplicationContext(); 
          String user = uid.getuser(); 
          MyApplication _tansId = (MyApplication) getApplicationContext(); 
          String trans_id = _tansId.getTransaction(); 
          Map<String, String> params = new HashMap<>(); 
          params.put("akey", "XXXXXX"); 
          params.put("userid", user); 
          params.put("transid", trans_id); 
          params.put("ewallet_checkbox", "off"); 

          Log.i(TAG, "Sending Value" + params); 
          return params; 
         } 
        }; 
        newApp.getInstance().addToRequestQueue(postRequest); 
       } 
      } 
     }); 
+0

Изменение положения в _Payment_full.startAnimation (slide_up); эту строку сначала нужно установить Длительность, чем начать – koutuk

+0

http://stackoverflow.com/questions/20374823/android-animate-my-relative-layout-from-bottom-to-top-and-top-to-bottom-using -tr – koutuk

+0

@ koutuk спасибо, но он идет в верхней части экрана Пожалуйста, помогите мне –

ответ

-1
_Payment_full.animate() 
      .translationYBy(100) 
      .translationY(0) 
      .setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)).start(); 
+0

Вы забыли начать его ... – caowenhua

+1

Пожалуйста, добавьте детали, объясняющие ваш ответ. –

+1

Пожалуйста, добавьте некоторое объяснение в свой ответ. Ответы только на код, как правило, считаются некачественными – Tristan

Смежные вопросы