android - setCompoundDrawables on drawable shape with no effect -
android - setCompoundDrawables on drawable shape with no effect -
i'm trying set overline textview using compound drawables. i've created line shape in xml drawable resource looks this:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#000000" /> <solid android:color="#00000000" /> </shape>
now i'm trying set overline textview this:
textview root=(textview)findviewbyid(r.id.root); drawable background=getresources().getdrawable(r.drawable.overline); root.setcompounddrawables(null,background,null,null);
but ignores instruction , overline doesn't appear. i've considered using compounddrawableswithintrinsicbounds, doesn't work either. xml shape wrong or using method in wrong way? give thanks much in advance!
edit: tried xml android:drawabletop property, still no luck. @ point think there's problem shape itself. finish code here:
activity_my.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".myactivity"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/hello" android:textsize="30sp" android:drawabletop="@drawable/overline" android:text="ciao" /> </relativelayout> overline.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#000000" /> <solid android:color="#00000000" /> </shape>
my java exact same 1 "hello world" default illustration given in android studio:
package tesi.bordengsberiment; import android.app.activity; import android.content.context; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.rect; import android.os.bundle; import android.util.attributeset; import android.util.log; import android.util.typedvalue; import android.view.menu; import android.view.menuitem; import android.view.viewtreeobserver; import android.widget.textview; public class myactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.my, menu); homecoming true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { homecoming true; } homecoming super.onoptionsitemselected(item); } }
i had experienced same problem before. want use root.setcompounddrawableswithintrinsicbounds();
android xml textview compound-drawables
Android - Setcompounddrawables On Drawable Shape With No Effect - >>>>> Download Now
ReplyDelete>>>>> Download Full
Android - Setcompounddrawables On Drawable Shape With No Effect - >>>>> Download LINK
>>>>> Download Now
Android - Setcompounddrawables On Drawable Shape With No Effect - >>>>> Download Full
>>>>> Download LINK Ux