버튼이 많은 보이지 않는 LinearLayout이 많은 상위 레벨 LinearLayout이 있습니다. 버튼을 누를 때마다 LinearLayout의 내용에 애니메이션을 적용하고 모든 것을 부드럽게 누르기를 원합니다. 대신에 큰 백색 공간을 즉시 조각 내고 LinearLayout을 우아하게 푸시 다운하는 대신 빈 공간으로 움직입니다.android animation이 부정확하게 애니메이션 됨
내 onCreate 메서드는 방대한 LinearList와 각 자식 LinearList의 모든 자식을 만듭니다. 이 코드를 실행하면 X 버튼이 0-19 인 20 개의 버튼 "버튼 X"가 표시됩니다. 버튼을 클릭하면 하위 메뉴처럼 들여 쓰기 된 버튼이 생기지 만 "버튼 X + 1"형태의 다음 버튼은 즉시 아래로 페인트되고 움직이지 않는 애니메이션은 푸시 다운됩니다.
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout topll = (LinearLayout)findViewById(R.id.topll);
for(int i=0;i<20;i++)
{
Button b = new Button(this);
b.setText("Button"+String.format("%s", i));
b.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
b.setOnClickListener(this);
topll.addView(b);
LinearLayout l = new LinearLayout(this);
l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
l.setVisibility(View.GONE);
l.setOrientation(LinearLayout.VERTICAL);
for(int k=0; k<10; k++)
{
Button b2 = new Button(this);
b2.setText("New Button"+String.format("%s", k));
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
p.setMargins(80, 0, 0, 0);
b2.setLayoutParams(p);
//b2.setOnClickListener(this);
l.addView(b2);
}
topll.addView(l);
}
}
그리고 여기에 모든 우선 사용
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:duration="1000"
android:startOffset="0"
android:fillAfter="false"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:toXScale="1.0"
android:pivotY="0%"/>
</set>
를 사용합니다. 그 결과 버튼을 누르면 초가 지나가고 모든 것이 나타납니다. onAnimationStart에 ll.setVisibility 호출을 넣으려고했지만 원래 문제가 발생했습니다. – Matthew