如何给文字添加阴影效果
package com.loaderman.customviewdemo; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView tv = (TextView)findViewById(R.id.tv); tv.setShadowLayer(2,5,5, Color.RED); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:gravity="center" android:background="@android:color/white" > <TextView android:id="@+id/tv" android:layout_width="match_parent" android:text="动态代码阴影效果" android:layout_gravity="center" android:gravity="center" android:textSize="18sp" android:layout_height="wrap_content" /> <TextView android:layout_width="match_parent" android:text="XML实现阴影效果" android:layout_gravity="center" android:gravity="center" android:textSize="18sp" android:shadowColor="@color/colorPrimary" android:shadowDx="5" android:shadowDy="5" android:shadowRadius="5" android:layout_height="wrap_content" /> </LinearLayout>
效果:
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!
posted on 2019-01-03 10:17 LoaderMan 阅读(1229) 评论(0) 编辑 收藏 举报