我目前在我的應用程序中有一個RelativeLayout,我動態地移動,調整大小和隱藏。移動一次之後,之後將佈局重新定位到奇怪的位置。LayoutParams在奇怪的位置放置視圖
這是我使用的佈局。
<RelativeLayout ...>
<RelativeLayout android:id="@+id/moveable_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:visibility="gone" />
</RelativeLayout>
這裏是我使用它,重新定位
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(newWidth, newHeight);
m_movingFrame.setEnabled(true);
m_movingFrame.setLayoutParams(layoutParams);
m_movingFrame.setX(newX);
m_movingFrame.setY(newY);
m_movingFrame.requestLayout();
m_movingFrame.bringToFront();
m_movingFrame.setVisibility(View.VISIBLE);
的代碼,這裏是用來隱藏佈局
m_movingFrame.setEnabled(false);
m_movingFrame.setVisibility(View.GONE);
的第一次,我重新定位它的代碼,它會移動到正確的位置,但每次後續的重新定位都會將其移動到錯誤的位置。誰能告訴我爲什麼它表現得如此不正常?
在此先感謝!
你沒問這個問題嗎? – Luksprog 2013-04-23 15:24:57
是的,但它沒有得到任何迴應,所以我用更具體的標題重新創建了它。 – loadedion 2013-04-23 15:45:14
請不要這樣做,編輯並改進您的原始問題。 – Luksprog 2013-04-23 15:49:48