Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here is the code used in the adapter to create the view :
- convertView = new TextView(context);
- convertView.setText("Test Text");
- convertView.setGravity(Gravity.CENTER);
- ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT);
- convertView.setLayoutParams(params);
- /**
- It is supposed to create a textView with full width, and put the text in the center of it.
- However, the TextViews behaves as if its width was put to WRAP_CONTENT in the LayoutParams...
- Also, if, instead of
- ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT);
- I use
- ListView.LayoutParams params = new ListView.LayoutParams(200, ListView.LayoutParams.WRAP_CONTENT);
- Then the TextView has the correct size (200) and the text is correctly centered...
- **/
Advertisement
Add Comment
Please, Sign In to add comment