【发布时间】:2016-05-02 05:42:25
【问题描述】:
如何在 Android 上创建 Drawable 如下所示:
删除
【问题讨论】:
-
你可以在drawable上画水平线
标签: android android-drawable xml-drawable
如何在 Android 上创建 Drawable 如下所示:
删除
【问题讨论】:
标签: android android-drawable xml-drawable
对于单个单词,我们可以使用 drawable。 以下是示例:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"><shape android:shape="line">
<stroke android:width="2dp" android:color="#ffffff" />
</shape>
</item>
</selector>
下面的多行使用:-
TextView tv=(TextView) v.findViewById(android.R.id.text1);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
使用您的参考而不是“tv”
【讨论】:
你可以这样做:
以编程方式:
TextView tv = (TextView) findViewById(R.id.mytext);
tv.setText("Remove");
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
来自 xml 文件:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@color/black"
android:layout_centerVertical="true"
/>
</RelativeLayout>
【讨论】: