total pixels for match_parent
of a view is depend on your parentView
type, dimensions and composition of views within the layout, for example if your parentView
is LinearLayout
of size 100px * 100px
then your match_parent
for a view within that LinearLayout
is 100px * 100px
(iff you have only one view within that LinearLayout
otherwise it depends on your composition) you can get your view's height
and width
(in pixels) programmatically to by using below code to any view
or Layout
Java
view.post(new Runnable(){
@Override
public void run() {
int height = view.getMeasuredHeight();
int width = view.getMeasuredWidth();
}
});
kotlin
view.post {
val width = view.measuredWidth
val height = view.measuredHeight
}
after getting height and width of layout you can manage you margin or size according to your logic