Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 24th, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. TextView objects and truncation on Android screens (designing for multiple screens)
  2. <TextView
  3. android:id="@+id/textView1"
  4. android:layout_width="wrap_content"
  5. android:layout_height="wrap_content"
  6. android:text="Small Text"
  7. android:textAppearance="?android:attr/textAppearanceSmall" />
  8.        
  9. <TextView
  10. android:id="@+id/textView1"
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:text="Medium Text"
  14. android:textAppearance="?android:attr/textAppearanceMedium" />
  15.        
  16. <TextView
  17. android:id="@+id/textView2"
  18. android:layout_width="wrap_content"
  19. android:layout_height="wrap_content"
  20. android:text="Large Text"
  21. android:textAppearance="?android:attr/textAppearanceLarge" />
  22.        
  23. <TextView
  24. android:id="@+id/textView1"
  25. android:layout_width="wrap_content"
  26. android:layout_height="wrap_content"
  27. android:text="This is your text"
  28. android:ellipsize="marquee" android:lines="1 />
  29.        
  30. android:lines="3"
  31. android:textIsSelectable="true"
  32. android:fadeScrollbars="false"
  33.        
  34. android:lines="3"
  35. android:clickable="true"
  36. android:onClick="showDef"
  37. android:ellipsize="start"
  38. android:isScrollContainer="false"
  39.        
  40. public void showDef(View v) {
  41.     AlertDialog.Builder builder = new AlertDialog.Builder(this);
  42.     builder.setMessage("same text as was set in the text view")
  43.         .setCancelable(false)
  44.         .setNegativeButton("Clear", new DialogInterface.OnClickListener() {
  45.             public void onClick(DialogInterface dialog, int id) {
  46.                 dialog.cancel();
  47.            }
  48.         });
  49.  
  50. AlertDialog alert = builder.create();
  51. alert.show()