Guest User

Untitled

a guest
Jan 13th, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. Here is the code used in the adapter to create the view :
  2.  
  3.  
  4. convertView = new TextView(context);
  5. convertView.setText("Test Text");
  6. convertView.setGravity(Gravity.CENTER);
  7.  
  8. ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT);
  9.  
  10. convertView.setLayoutParams(params);
  11.  
  12. /**
  13.  
  14. It is supposed to create a textView with full width, and put the text in the center of it.
  15. However, the TextViews behaves as if its width was put to WRAP_CONTENT in the LayoutParams...
  16. Also, if, instead of
  17.  
  18. ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT);
  19.  
  20. I use
  21.  
  22. ListView.LayoutParams params = new ListView.LayoutParams(200, ListView.LayoutParams.WRAP_CONTENT);
  23.  
  24. Then the TextView has the correct size (200) and the text is correctly centered...
  25.  
  26. **/
Advertisement
Add Comment
Please, Sign In to add comment