When editing XML layout files, Eclipse has a feature called 'wrap in container' (Reformat -> Android -> ...) that lets you select one or several Views and wrap a layout of your choice around it. Is there something similar in Android Studio?
“how to wrap code in android studio” Code Answer "File->Settings->Editor->General" tab and check "Use soft wraps in editor".
Please goto "File->Settings->Editor->General" tab and check "Use soft wraps in editor". it will solve your problem.
To efficiently re-use complete layouts, you can use the <include/> and <merge/> tags to embed another layout inside the current layout. Reusing layouts is particularly powerful as it allows you to create reusable complex layouts.
It's currently being implemented: Issue 69000: Add the "Wrap In" visual refactoring - Android Issue Tracker
Tor Norbye, Android Issue Tracker Mantainer:
We should implement the "Wrap In" visual refactoring.
Just came across this, and to complete Simas' answer:
using AS1.2, this is easy to achieve...
Alt+Shift+Z
(surround-with)... a little
popup appears. Click Configure Live Templates...
. Or use File->Settings->Editor->Live Templates
as described above.Select the html/xml
section and hit the little +
. Give it a name and description, then fill in template text:
<LinearLayout
android:orientation="$ORIENTATION$"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
$SELECTION$
</LinearLayout>
Click Edit variables
, set Expression:complete()
, Default value:vertical
... hit OK. Then, find the Define
' button for applicable context... and select XML.
You're all set now. To use the template, select the View that you wanna surround in the XML, hit Alt+Shift+Z
(surround-with)... a little popup appears. Select the template you just defined... Done!
You can use Live Templates for that. Here's a nice article about them.
Edit:
New templates can be added through File->Settings->Editor->Live Templates
.
To find the hotkey for your keymap go to File->Settings
and write "Live template". For me it's CTRL + J .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With