Changing shape of textview in Android framework -
i working on android frameworks. need modify shape of textview such should have rounded corners. can please me issue?
xml file saved @ res/drawable/gradient_box.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startcolor="#ffff0000" android:endcolor="#80ff00ff" android:angle="45"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /> </shape> this layout xml applies shape drawable view:
<textview android:background="@drawable/gradient_box" android:layout_height="wrap_content" android:layout_width="wrap_content" /> this application code gets shape drawable , applies view: resources res = getresources(); drawable shape = res. getdrawable(r.drawable.gradient_box);
textview tv = (textview)findviewbyid(r.id.textview); tv.setbackground(shape); copy&paste http://developer.android.com/guide/topics/resources/drawable-resource.html, first result when google "android textview rounded corners"
[edit]
as want change source of android framework, can alter style of textview altering default drawables. in sources various drawables grouped in inner class called drawables:
class drawables { final rect mcompoundrect = new rect(); drawable mdrawabletop, mdrawablebottom, mdrawableleft, mdrawableright; int mdrawablesizetop, mdrawablesizebottom, mdrawablesizeleft, mdrawablesizeright; int mdrawablewidthtop, mdrawablewidthbottom, mdrawableheightleft, mdrawableheightright; int mdrawablepadding; } just alter these drawables , have redefined textview.
i'm referring version of textview sources.
Comments
Post a Comment