我想做一个虚线.我现在正在使用这个实线:
LinearLayout divider = new LinearLayout( this );
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 2 );
divider.setLayoutParams( params );
divider.setBackgroundColor( getResources().getColor( R.color.grey ) );
Run Code Online (Sandbox Code Playgroud)
我需要这样的东西,但点缀而不是坚实.我想避免在透明布局和实体布局之间交替进行数百种布局.
我厌倦了用文字中的一个特定单词加下划线,用虚线或虚线表示,还有Clickable Span.
我没有找到解决方案,有人可以帮助我.
SpannableStringBuilder sb = new SpannableStringBuilder(text); List listmot = new ArrayList();
listmot=db.getAlldef();
for(int i=0;i<listmot.size();i++)
{
String mot = (listmot.get(i)).get_mot();
final String def = (listmot.get(i)).get_definition();
Log.v(null, mot);
Pattern p = Pattern.compile(mot, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(text);
while (m.find()){
// Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(),"fonts/font.ttf");
//sb.setSpan(new CustomTypefaceSpan("",tf), m.start(), m.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sb.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
// Toast.makeText(getApplicationContext(), def,Toast.LENGTH_LONG).show();
int[] values = new int[2];
widget.getLocationOnScreen(values);
Log.d("X & Y",values[0]+" "+values[1]);
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
AndroidSQLiteTutorialActivity.this);
alertDialog.setMessage(def);
alertDialog.setCancelable(true);
AlertDialog …Run Code Online (Sandbox Code Playgroud)