爲了產生效果,我放大了導致子視圖在其父視圖外側的子視圖。我在子視圖中有一個按鈕,它在縮放之前工作,但在縮放之後不起作用。發生了什麼問題?見下圖:Android:父級以外的子視圖不響應點擊事件
縮放孩子,我用這個代碼:
childView.bringToFront();
Animation a = new Animation() {
@Override
protected void applyTransformation(float t, Transformation trans) {
float scale = 1f * (1 - t) + SCALE_UP_FACTOR * t;
childView.setScaleX(scale);
childView.setScaleY(scale);
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration(ANIM_DURATION);
a.setInterpolator(new Interpolator() {
@Override
public float getInterpolation(float t) {
t -= 1f;
return (t * t * t * t * t) + 1f; // (t-1)^5 + 1
}
});
childView.startAnimation(a);
父是ViewPager
:
<ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/invoice_list_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f5f5f5"
android:layout_gravity="center"
android:clipChildren="false"
android:clipToPadding="false"
/>
請在您的活動或片段中提供您的代碼,並提供您的佈局的xml –
如果在縮放視圖時點擊其原始(未縮放)位置,該按鈕是否會響應? – Barend
@Barend正如我在提到的問題:「它在縮放之前工作,但縮放後不起作用」 – Mneckoee