I want to achieve an animation of the shift of views to the right when adding a new view.
I am using LayoutTransition Animation LayoutTransition.APPEARING. I add a new view at the 0th position of the linear layout.
It works fine, except in one case where a view is added from onActivityResult ().
When I run an Activity for the result and try to add a view to the onActivityResult () method, the view is added, however the LayoutTransition animation works.
Scenario 1: Action A starts action B for the result. Action B setResult () and finish () without any action. In this case, the LayoutTransition animation works fine.
Scenario 2: Action A starts action B for the result. In operation B there is a button. When you click Action B setResult () and finish (). In this case, the LayoutTransition animation does not work.
You need to enter data about where I am mistaken, or a workaround to achieve the animation.
Activity A
private LinearLayout ll; private Button b, addbutton, setResultButton; private LayoutTransition transitioner; private Animator defaultAppearingAnim; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test); ll = (LinearLayout) findViewById(R.id.ll); transitioner = new LayoutTransition(); defaultAppearingAnim = transitioner .getAnimator(LayoutTransition.APPEARING); transitioner.setAnimator(LayoutTransition.APPEARING, defaultAppearingAnim); ll.setLayoutTransition(transitioner); addbutton = (Button) findViewById(R.id.button1); addbutton.setOnClickListener(this); setResultButton = (Button) findViewById(R.id.button2); setResultButton.setOnClickListener(this); for (int i = 0; i < 2; i++) { Button b = new Button(this); b.setText("B " + i); ll.addView(b); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Activity B
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.result); Button setResultButton = (Button) findViewById(R.id.button11); setResultButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) {
source share