在Android中,是否可以像这样在
TextView
的文本上添加内部阴影:
TextView
的文本上添加内部阴影:
MagicTextView将会产生内部阴影。
<com.qwerjk.better_text.MagicTextView
xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text"
android:textSize="42dp"
android:textColor="#FFffff00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:padding="10dp"
qwerjk:innerShadowDy="3"
qwerjk:innerShadowColor="#FF000000"
qwerjk:innerShadowRadius="5"
android:text="InnerShadow" />
阴影效果:
<TextView
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:paddingTop="15sp"
android:paddingBottom="15sp"
android:typeface="normal"
android:text="I'm normal (bold) font but I have a shadow"
android:textSize="16sp"
android:textStyle="bold"
android:shadowColor ="#0f0f0f"
android:shadowRadius="1.6"
android:shadowDx="1.5"
android:shadowDy="1.3"
android:textColor="#000000"
android:background="#ffffff"
/>
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "my_font.ttf");
txt.setTypeface(font);
或者查看以下链接了解详细信息:
http://www.barebonescoder.com/2010/05/android-development-using-custom-fonts/
和
这是我几个月前问过的一个问题的副本:有没有办法在Android上的TextView中添加内阴影?
目前还没有合适的方法来实现这一点。但如果你尝试调整文本颜色的alpha值和投影的阴影效果,你最终可以得到类似内阴影的效果。