Android negative margin does not work
I have encountered a problem where i try to give a negative left margin to
LinearLayout. The negative margin does not appear. here is my code
HorizontalScrollView hview = new HorizontalScrollView(context); //
HorizontalScrollView is the outer view
RelativeLayout.LayoutParams hs_lot_params = new
RelativeLayout.LayoutParams(164, 164);
hs_lot_params.setMargins(100, 100, 0, 0); // set the positions
ImageView image = new ImageView(context);
image.setBackgroundResource(R.drawable.leder);
LinearLayout.LayoutParams img_lot_params = new
LinearLayout.LayoutParams(164, 164);
img_lot_params.setMargins(0, 0, 0, 0);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(164, 164);
layoutParams.setMargins(-132, 0, 0, 0);
ll.addView(image, img_lot_params);
hview.addView(ll, layoutParams);
Note: my plan is to scroll the image from left to right. First, the left
part of the image is hidden and can scroll to right to see full image
No comments:
Post a Comment