tôi sử dụng ObjectAnimator phải thu hẹp một RelativeLayout:ObjectAnimator với tài sản quy mô làm cho màu đen bg?
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 0.5f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 0.5f);
scaleDownY.setDuration(1000);
AnimatorSet scaleDown = new AnimatorSet();
scaleDown.play(scaleDownX).with(scaleDownY);
scaleDown.start();
Nó quy mô xuống khá tốt như mong đợi, nhưng vấn đề là các khu vực xung quanh xem bây giờ nhỏ hơn là màu đen cho đến khi một hành động của người dùng, mà là không mong muốn. Tôi muốn nó để phù hợp với nền của cha mẹ của xem tỉ lệ. Bất kỳ ý tưởng làm thế nào để làm cho khu vực xung quanh hình vuông màu đỏ có màu sắc chính xác ngay lập tức?
xml của tôi:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:gui="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bg"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity$DummySectionFragment">
<RelativeLayout
android:id="@+id/res1"
android:layout_width="50dp"
android:layout_height="50dp"
android:tag="res1"
android:background="@android:color/holo_red_dark"
android:layout_alignTop="@+id/res2"
android:layout_alignRight="@+id/include3"
android:layout_marginRight="11dp">
<TextView
android:layout_marginLeft="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="res1"
android:id="@+id/res1T"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</RelativeLayout>
Tôi nghĩ về điều đó, nhưng phụ huynh bị mất hiệu lực khoảng 20 lần, trong đó có thể là một khối lượng công việc không cần thiết. Vâng, cho đến khi tôi tìm thấy một số giải pháp tốt hơn tôi đoán tôi sẽ phải sống với this.thx – slezadav
Câu trả lời khác là sạch hơn và tốt hơn – afollestad
"scaleX" và "scaleY" có thể được thay thế bằng View.SCALE_X.getName() và View. SCALE_Y.getName() – dor506