If you find that the "android:" attribute prefix is cumbersome and
reduces the readability of your Android XML files, you might want to
try changing the prefix from android to _. If you do it via the
Eclipse XML editor, it seems like you have to perform 2 find/replace
operations with regular expressions. This is itself a cumbersome
task, so you can automate it:
1) Download AutoHotKey, which lets you write a script to send keys
and mouse clicks to a program. I believe that AutoKey does the same
for linux.
2) Write a script to tell Eclipse to perform a find/replace, scope is
all, wrap search, regular expressions on, 1st find expression is
(xmlns:)android, 1st replace expression is \1_. 2nd find expression
is (\s)android: and 2nd replace expression is \1_:. I also added in
format and save commands, so my AutoHotKey script is:
^!a::
Send ^f!f(xmlns:)android!e\1_!a!f(\s)android:!e\1_:!a{Escape}^+f^s
The result is a single-keystroke (Ctrl-Shift-a) to change a layout
file from:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="User name"
android:textColor="#ffffff"
android:textSize="20sp"
android:layout_margin="5dp" />
<EditText
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_width="fill_parent"></EditText>
</LinearLayout>
to
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:_="http://schemas.android.com/apk/res/android"
_:orientation="vertical"
_:layout_width="fill_parent"
_:layout_height="fill_parent">
<TextView
_:layout_width="fill_parent"
_:layout_height="wrap_content"
_:text="User name"
_:textColor="#ffffff"
_:textSize="20sp"
_:layout_margin="5dp" />
<EditText
_:id="@+id/EditText01"
_:layout_height="wrap_content"
_:layout_margin="5dp"
_:layout_width="fill_parent"></EditText>
</LinearLayout>
If anyone runs into a problem using this approach, or finds a better
solution, please pass it along.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en