Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to setLayoutParams on dynamically added elements on Widget
- RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_design);
- RemoteViews newView = new RemoteViews(context.getPackageName(), R.layout.widget_item);
- views.addView(R.id.view_container, newView);
- LinearLayout item = (LinearLayout) ((Activity) context).findViewById(R.id.widgetItem);
- MarginLayoutParams marginParams = new MarginLayoutParams(item.getLayoutParams());
- marginParams.setMargins(10, 50, 4, 5);
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(marginParams);
- item.setLayoutParams(layoutParams);
- LinearLayout layoutParams = item.getLayoutParams();
- layoutParams.setMargins(10, 50, 4, 5);
- item.setLayoutParams(layoutParams);
- private static void adjustViewHeight(int resID, int pixels, Activity activity){
- ((FrameLayout.LayoutParams)activity.findViewById(resID).getLayoutParams()).bottomMargin = pixels;
- activity.findViewById(resID).invalidate();
- activity.findViewById(resID).requestLayout();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement