I created my own layout class (extends RelativeLayout) and has a TextView as part of the layout.
I want to apply the properties declared in XML to my TextView, anyway I can read the android attributes (and not my user attributes, this part has already taken care).
For example, in my XML, I will have this:
<my.custom.MyLayout
android:layout_width="100dp"
android:layout_height="20dp"
android:text="SomeText" />
I want to read a text attribute and apply it to my TextView (it is currently applied to RelativeLayout) instead of creating my own attribute and reading it.
My custom layout looks something like this:
public class MyLayout extends RelativeLayout {
private TextView textView;
public void MyLayout(final Context context, final AttributeSet attrs) {
??
}
My current solution is to create custom attributes and read them, but I think this is not a good solution, as I will duplicate every attribute declared in TextView.
.
myText, , XML, TextView.
XML:
myNameSpace:myText="SomeText"
Java:
String text= a.getString(R.styleable.MyStyleable_myText);
textView.setText(text);
"android:".