java - How can I bypass parent's attributeset to child in android -


i creating compond view imageview + textview imagetextview follow in xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="horizontal"     android:layout_width="wrap_content"     android:layout_height="match_parent"     > <button android:id="@+id/btnview" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <textview android:id="@+id/txtview" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </linearlayout> 

in usage, want use imagetextview follow:

<com.mypkg.myclass.imagetextview          android:layout_width="wrap_content"         android:layout_height="50dp"         android:text="text textview"   //used textview         android:background="@drawable/background.png"  //used image view /> 

in imagetextviewconstructor, want bypass textsize, text, textcolor , textview's attributes child txtview without layoutparams following logic, how can filter attributeset in java code.

public imagetextview(context context, attributeset attrs) {         super(context, attrs);          //------------------------------         // attributeset filteredattrs= filterattributeset(attrs);         //i want remove layoutparams , background parent attributeset         //------------------------------        textview mtxtview=(textview)findviewbyid(r.id.txtview);         mtxtview=new textview(this,filteredattrs);     } 

textview can contain drawable on top, bottom, left (start) and/or right (end).

<textview   ...   android:drawablepadding="4dp"   android:drawableleft="@drawable/my_drawable"/> 

more on topic here: http://antonioleiva.com/textview_power_drawables/


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -