2
보기의 일부가 다른 색상으로 채워지는 전환/애니메이션을 만들려고합니다. 이 같은애니메이션으로 사용자 정의보기 채우기 (Android)
뭔가 :
어떻게이 작업을 수행하는 가장 쉬운 방법이 될 것입니다?
보기의 일부가 다른 색상으로 채워지는 전환/애니메이션을 만들려고합니다. 이 같은애니메이션으로 사용자 정의보기 채우기 (Android)
뭔가 :
어떻게이 작업을 수행하는 가장 쉬운 방법이 될 것입니다?
다음과 같은 시도 할 수 :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View progress = findViewById(R.id.progress);
// from -1 to 0
float desiredPercentage = -0.6f;
TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1,
Animation.RELATIVE_TO_PARENT, desiredPercentage, Animation.RELATIVE_TO_PARENT,
0, Animation.RELATIVE_TO_PARENT, 0);
anim.setDuration(3000);
anim.setFillAfter(true);
progress.startAnimation(anim);
progress.setVisibility(View.VISIBLE);
}
그리고 레이아웃 :
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:background="@android:color/holo_green_dark">
<View
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_dark"
android:visibility="invisible"
/>
</LinearLayout>
그것이
희망이 도움