Is there a way to reuse an XML declaration of a UI component in Android? -
i've done snooping around feel relatively simple, however, guess wasn't quite sure how phrase question because wasn't getting many results. apologize if duplicate question. want define edittext
attributes so:
<edittext android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputtype="numberdecimal" android:background="#00000000" android:digits="0123456789.," android:ellipsize="start" android:maxlines="1" android:gravity="center" android:hint=" "/>
and there, wish declare myedittext
(assuming above definition called myedittext), , not have worry defining these 9 attributes every time wish use edittext
of style. possible? have read through android's guide custom components, however, seems overkill trying accomplish. (i not wish custom persay, i'm looking package existing functionality single component.) point me in right direction?
thank you!!
use style this. can create style as-
<style name="edittext"> <item name="android:layout_width">@dimen/text_box_width</item> <item name="android:maxlines">2</item> <item name="android:textcolor">#000000</item> <item name="android:textsize">15sp</item> <item name="android:layout_marginleft">40dp</item> <item name="android:gravity">left</item> </style>
and can set style in layout file as
<edittext style="@style/edittext" />
Comments
Post a Comment