두 개의 텍스트 뷰가있는 애니메이션을 만들려고합니다. 둘 다 상대 레이아웃에 있습니다. 애니메이션의 기능은 그대로두고 텍스트 뷰는 약간 왼쪽으로 가고 동시에 텍스트 뷰도 만듭니다. 조금 남았 어. 시도 : -여러보기가있는 슬라이딩 애니메이션 동기화 문제
http://nineoldandroids.com/ 및 기본 방법.
Android slider animation is not synchronized
Nineoldandroids 코드 :
- :
그러나 두 경우에 나는 process.I 동안 격차가 이미 하나 개의 질문을 넣어 무엇입니까하지만 난 어떤 긍정적 인 답변을 받고 있지 않다 xml 파일 : -
<RelativeLayout
android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/target"
android:layout_marginTop="50dp">
<TextView
android:id="@+id/TextView01"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:background="#f00"
android:gravity="center"
android:text="RED"
android:textColor="#000" />
<Button
android:id="@+id/TextView02"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/TextView01"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/TextView01"
android:background="#0F0"
android:text="TXT"
android:visibility="invisible" />
</RelativeLayout>
MainActivity.java : -
public class MainActivity extends Activity {
double counter = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.toggles);
final View target = findViewById(R.id.target);
final int duration = 5*1000;
final int duration1 = 300;
final View textView1 = findViewById(R.id.TextView01);
final View textView2 = findViewById(R.id.TextView02);
textView1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (counter == 0) {
textView2.setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(textView1, "translationX", 0, -50).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 100, 0).setDuration(duration1).start();
counter++;
}
else {
ObjectAnimator.ofFloat(textView1, "translationX", -50,0).setDuration(duration1).start();
ObjectAnimator.ofFloat(textView2, "translationX", 0,100).setDuration(duration1).start();
counter--;
}
}
});
}
}
어떻게 해결할 수 있습니까?
그렇지 않으면 두 번째 textview가 화면 외부에 있고 애니메이션을 사용하여 layoutview 내부에 textview를 넣으려고합니다. 전체 layout.how를 움직일 수 있습니까? 이처럼 xml을 만들 수 있습니까?
당신은 당신은 다시 말하면 115 (100)에서 사용한다 (100)에 85에서 blackRight에 사용, 115에서 100까지 사용하십시오. –
죄송합니다. 작동하지 않습니다. – Nullify
현재 결과를 표시 할 수 있습니까? 첫 번째 텍스트 뷰가 현재 올바르게 슬라이딩되는 경우 '100, 0'및 '0, 100'대신 '0, 50'및 '50, 0'을 사용하여 두 번째 텍스트 뷰를 슬라이드합니다. –