ARTICLE AD BOX
I have created custom UI component that is basically two text boxes inside a linear layout and I want to be able to control the width of each text control so I have created a declared styleable like this
<declare-styleable name="TLPTextLabelAndData"> <attr name="labelWidth" format="dimension" /> <attr name="labelStyle" /> <attr name="labelText" /> <attr name="icon" /> <attr name="iconColor" /> <attr name="dataWidth" format="dimension" /> <attr name="dataStyle" format="reference" /> <attr name="dataText" format="string" /> </declare-styleable>The code for my UI works as expected if I put all the values above in the UI XML
<com.tlpsoftware.ui.TLPTextLabelAndData app:dataWidth="100dp" app:dataText="data 3" app:labelWidth="60dp" app:labelText="label 3" android:id="@+id/id_label_data_3" android:layout_width="match_parent" android:layout_height="wrap_content" app:dataStyle="@style/styleDataValue" app:labelStyle="@style/styleDataLabel" />However, if I put the "dataWidth" or "labelWidth" inside the @styles the values are ignored.
<style name="styleDataValue"> <item name="dataWidth">200dp</item> <item name="android:paddingStart">8dp</item> <item name="android:typeface">normal</item> <item name="android:textSize">9pt</item> </style>Is there another way I need to reference dataWidth in the style sheet? I tried app:dataWidth but that gives me an error. Do I need to set the parent on my style? Do I need to wrap my TLPTextLabelAndData attributes inside some other XML element to make them "seen" in the <style>?
