Generate style from xml in intellij (/android studio)
Very Simple.!
Just keep the cursor in the file from where you want to extract the style resource. Just a right click then click on refactor.
Refactor -> Extract -> style/layout.
Then give style a name and there you go..!For more you can refer the documentation.
Try something like that:
<resources> <style name="CustomImgView"> <item name="android:layout_width">80dp</item> <item name="android:layout_height">47dp</item> </style></resources><ImageView style="@style/CustomImgView" />
more information: https://developer.android.com/guide/topics/resources/style-resource.html
Try to Declare your Style like this :
<?xml version="1.0" encoding="utf-8" ?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="YourCustomStyle"> <item name="android:layout_width">"80dp"</item> <item name="android:layout_height">"47dp"</item> <!-- another attributes --> <item name="customAttr">value</item> </style> </resources>
And in your xml
add this android:theme="@style/YourCustomStyle"