Posts

Showing posts with the label android-custom-view

Set custom style to textviews inside a custom view in android

Set custom style to textviews inside a custom view in android I have a custom view class DoubleTextView.java which looks like below, public class DoubleTextView extends LinearLayout { LinearLayout layout; TextView upTextView; TextView downTextView; Context mContext; public DoubleTextView(Context context) { super(context); mContext = context; } public DoubleTextView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; String service = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater li = (LayoutInflater) getContext().getSystemService(service); layout = (LinearLayout) li.inflate(R.layout.custom_double_text, this, true); upTextView = layout.findViewById(R.id.text_up); downTextView = layout.findViewById(R.id.text_down); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DoubleTextView); String upText = a.getString(R.styleable.DoubleTe...