Android style resource, Android Studio automatically extracts the control style style tutorial

For example, sometimes it seems very laborious and troublesome to write hundreds of lines in a layout. At this time, it is necessary to extract the control style. Android Studio provides a way to extract the style style. It may be hidden too deep, and few people use

The cursor is placed in the control: Right-click –>Refactor –> Extract –>Style…

78642bd4a3a9da14352c93fb8ee4dcf4.png

After selecting, a dialog box pops up:

7a7b9f2b8cb1ba8233d9815746f0cea3.png

If you use it a lot, you can also set a shortcut key for it:

Open the Android Studio settings page, search for extract in the Keymap, and that's it for Style, then right-click on Style to add a shortcut key for it

67a1dd062a2491ed6850e16d35b8d740.png

A pop-up window will pop up, just press the shortcut key you want to set and it will be OK, and then confirm

a732086fe8a91d68f08081676433f2c3.png

Then just use the shortcut keys and have fun

Supplementary knowledge: Android Studio Button beautification

Change the corner, fill color and border color of the button Button control.

step:

Create a new btn_all_shape.xml in res>drawable:

android:bottomLeftRadius="15dp"

android:bottomRightRadius="15dp"

android:topLeftRadius="15dp"

android:topRightRadius="15dp" />

Add this sentence to the xml of the key you want to change:

android:background="@drawable/btn_all_shape"

The above Android Studio automatic extraction control style style tutorial is all the content shared by the editor. I hope it can give you a reference, and I hope you can support the free resource network.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324138875&siteId=291194637