Android : why shape can not be appied to the textview in android

on Sunday, October 26, 2014


I am a newer to android, and I have got this problem:the shape drawable can not be applied to the textview. The java code in my textview as below:



shape = getResources().getDrawable(R.drawable.shape_tag_round_corner);
this.setBackgroundDrawable(shape);
this.setBackgroundColor(color);
this.setText(roleName);
this.setGravity(Gravity.CENTER);


shape xml file as below:



<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp"></corners>
<padding
android:left="5dp"
android:top="0dp"
android:right="5dp"
android:bottom="0dp"
/>
</shape>


finally,the textview didnot get the shape and the color setted int the code,why?


0 comments:

Post a Comment