I am adding two views to a linearlayout. When I click on the first view it has to occupy second views width also. How do I do that?
2 Answers
This code sets the width and height of yourView that was placed inside a RelativeLayout.
int viewWidth = 69; int viewHeight = 69; RelativeLayout.LayoutParams newViewParams = new RelativeLayout.LayoutParams(viewWidth, viewHeight); View v = (View)findViewById(R.id.yourView); v.setLayoutParams(newViewParams); Alternatively, for a LinearLayout, you need to use this:
LinearLayout.LayoutParams newViewParams = new LinearLayout.LayoutParams(viewWidth, viewHeight);