比如说有一张图片,我想让这张图片的中心距离父 view 的左边距是 x,图片大小不一定,这个操作在 Android 下该如何完成呢?
巴扎黑2017-04-17 17:39:02
Move the original left margin to the left by half the width of the image, that is, subtract half the width of the image.
If the image width is not sure, you can wait until it is confirmed and then dynamically change it.
PHP中文网2017-04-17 17:39:02
If the poster's x is a fixed value, just use layout_marginLeft to get it. If it is a changing value, control it in the code.