@@ -1183,8 +1183,7 @@ public void apply(View root, ViewGroup rootParent) {
11831183 }
11841184
11851185 /**
1186- * Helper action to set compound drawables on a TextView. Supports relative
1187- * (s/t/e/b) or cardinal (l/t/r/b) arrangement.
1186+ * Helper action to set text size on a TextView in any supported units.
11881187 */
11891188 private class TextViewSizeAction extends Action {
11901189 public TextViewSizeAction (int viewId , int units , float size ) {
@@ -1221,6 +1220,49 @@ public void apply(View root, ViewGroup rootParent) {
12211220 public final static int TAG = 13 ;
12221221 }
12231222
1223+ /**
1224+ * Helper action to set padding on a View.
1225+ */
1226+ private class ViewPaddingAction extends Action {
1227+ public ViewPaddingAction (int viewId , int left , int top , int right , int bottom ) {
1228+ this .viewId = viewId ;
1229+ this .left = left ;
1230+ this .top = top ;
1231+ this .right = right ;
1232+ this .bottom = bottom ;
1233+ }
1234+
1235+ public ViewPaddingAction (Parcel parcel ) {
1236+ viewId = parcel .readInt ();
1237+ left = parcel .readInt ();
1238+ top = parcel .readInt ();
1239+ right = parcel .readInt ();
1240+ bottom = parcel .readInt ();
1241+ }
1242+
1243+ public void writeToParcel (Parcel dest , int flags ) {
1244+ dest .writeInt (TAG );
1245+ dest .writeInt (viewId );
1246+ dest .writeInt (left );
1247+ dest .writeInt (top );
1248+ dest .writeInt (right );
1249+ dest .writeInt (bottom );
1250+ }
1251+
1252+ @ Override
1253+ public void apply (View root , ViewGroup rootParent ) {
1254+ final Context context = root .getContext ();
1255+ final View target = root .findViewById (viewId );
1256+ if (target == null ) return ;
1257+ target .setPadding (left , top , right , bottom );
1258+ }
1259+
1260+ int viewId ;
1261+ int left , top , right , bottom ;
1262+
1263+ public final static int TAG = 14 ;
1264+ }
1265+
12241266 /**
12251267 * Simple class used to keep track of memory usage in a RemoteViews.
12261268 *
@@ -1377,6 +1419,9 @@ private RemoteViews(Parcel parcel, BitmapCache bitmapCache) {
13771419 case TextViewSizeAction .TAG :
13781420 mActions .add (new TextViewSizeAction (parcel ));
13791421 break ;
1422+ case ViewPaddingAction .TAG :
1423+ mActions .add (new ViewPaddingAction (parcel ));
1424+ break ;
13801425 case BitmapReflectionAction .TAG :
13811426 mActions .add (new BitmapReflectionAction (parcel ));
13821427 break ;
@@ -1853,6 +1898,20 @@ public void setRelativeScrollPosition(int viewId, int offset) {
18531898 setInt (viewId , "smoothScrollByOffset" , offset );
18541899 }
18551900
1901+ /**
1902+ * @hide
1903+ * Equivalent to calling {@link View#setPadding(int, int, int, int)}.
1904+ *
1905+ * @param viewId The id of the view to change
1906+ * @param left the left padding in pixels
1907+ * @param top the top padding in pixels
1908+ * @param right the right padding in pixels
1909+ * @param bottom the bottom padding in pixels
1910+ */
1911+ public void setViewPadding (int viewId , int left , int top , int right , int bottom ) {
1912+ addAction (new ViewPaddingAction (viewId , left , top , right , bottom ));
1913+ }
1914+
18561915 /**
18571916 * Call a method taking one boolean on a view in the layout for this RemoteViews.
18581917 *
0 commit comments