Android widget : set width/height or x/y programmability

443 views Asked by At

How to access UI element style from widget and how to setup position or dimension ?

I know for setText :

RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widgetlayout);
remoteViews.setTextViewText(R.id.updateText, "New text");

but how to implement this

ViewGroup.LayoutParams paraPlay1 = PLAY_BTN1.getLayoutParams();
Double d1 = (200.0);
paraPlay1.width = d1.intValue();
paraPlay1.height = d1.intValue();
PLAY_BTN1.setLayoutParams(paraPlay1);
1

There are 1 answers

1
Zakir hussain On BEST ANSWER

`you can set heigth and width of view using the below code :

view.getLayoutParams().height = 20; view.getLayoutParams().width = 20;

but make sure call the below code also :

view.requestLayout()`