I have many of
android:layout_width="fill_parent"
&
android:layout_height="wrap_content"
properties in my app project. So i would like to add them in styles like the below.
<style name="layout_wf_hw">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="layout_ww_hw">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
styles.xml
<style name="inputbox" parent="layout_wf_hw">
<item name="android:background">@drawable/editviewstyle</item>
</style>
Now my code view is
<EditText style="@style/inputbox"/>
My question is can we apply like this? Is this right way what i followed?
Thanks
I don't see anything which is not allowed in your code.
Actually I think it's respecting DRY principle, and that's a good thing.
The only thing which might be annoying is that maybe it's a little bit more difficult to understand and read for other developers on the first time.
So my answer is: why not.
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