February 15, 2011

Converting attributes of a view in layout to attributes in styles

If you are developing for android and want quickly convert text like
     
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:text="Congratulations!"
          android:textColor="@color/setup_tracking_title"
          android:textSize="32dip"
          android:textStyle="bold"
          android:layout_marginTop="40dip"
          android:shadowColor="#ffffffff"
          android:shadowDy="1"
          android:shadowDx="0"
          android:shadowRadius="1"/>
to style format
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:text">Congratulations!</item>
<item name="android:textColor">@color/setup_tracking_title</item>
<item name="android:textSize">32dip</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_marginTop">40dip</item>
<item name="android:shadowColor">#ffffffff</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowRadius">1</item>
Use this  regular expression \s*([^=]+)="([^"]*)" for finding and this value for replacing <item name="\1">\2</item>

No comments: