Expected Result
In onClick()
callback method, programmatically set a new position for linear layout.
Problem
Neither the linear layout nor the button can be placed to a new place.
Source Code
Main.java > public class MainActivity extends Activity {}
Neither of the following two code snippet works.
(1)
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(480, 800); // unit is pixel
params.leftMargin = 420; // Shift 420 pixels from left screen border
params.rightMargin = -60; // Exceed 60 pixels from right screen border
mLinearLayout.setLayoutParams(params);
(2)
Button mButtonMenu = (Button) findViewById(R.id.button_menu);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(80, 55); // unit is pixel
params.leftMargin = 420; // unit is pixel
params.rightMargin = -60; // unit is pixel
mButtonMenu.setLayoutParams(params);
activity_main.xml
> elements structure
<FrameLayout
<ScrollView <!-- The menu -->
</ScrollView>
<LinearLayout <!-- The content -->
<Button />
<TextView />
</LinearLayout>
</FrameLayout>