Akr*_*ram 4 android textview dropshadow
我尝试使用xml文件和代码将阴影添加到自定义字体,但没有任何成功
我的代码是
TextView text=(TextView)findViewById(R.id.text1);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/gillsans.ttf");
text.setTypeface(tf);
Run Code Online (Sandbox Code Playgroud)
用这个:
Activity.class:
TextView text=(TextView)findViewById(R.id.text1);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/gillsans.ttf");
text.setTypeface(tf);
////////////
Shader textShader=new LinearGradient(2, 0, 4, 60,
new int[]{Color.parseColor("#b4e391"),Color.parseColor("#61c419"),Color.parseColor("#b4e391")},
new float[]{0, 3,1}, TileMode.MIRROR);
text.getPaint().setShader(textShader);
Run Code Online (Sandbox Code Playgroud)
main.xml中:
<TextView
android:id="@+id/text1"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:shadowDx="5"
android:shadowDy="5"
android:layout_marginRight="42dp"
android:layout_marginTop="-10dp"
android:layout_gravity="right|center_vertical"
android:shadowColor="#67587686"
android:shadowRadius="3"
android:textSize="25dp"
android:text="99%" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2138 次 |
最近记录: |