Android 如何将TextView的宽度设置为高度并重新绘制?
我在expandableListView的标题行中有notesCenter(TextView)。我想画一个相等的圆。TextView高度设置为与父项匹配。现在开始我的问题。。。我想将椭圆形的宽度设置为与高度相同。我测量它,它会返回正确的值(高度),我将它设置为TextView,但它不会刷新。我的问题:如何刷新文本视图Android 如何将TextView的宽度设置为高度并重新绘制?,android,expandablelistview,Android,Expandablelistview,我在expandableListView的标题行中有notesCenter(TextView)。我想画一个相等的圆。TextView高度设置为与父项匹配。现在开始我的问题。。。我想将椭圆形的宽度设置为与高度相同。我测量它,它会返回正确的值(高度),我将它设置为TextView,但它不会刷新。我的问题:如何刷新文本视图 @Override public View getGroupView(int groupPosition, boolean isExpanded, View rowView, Vi
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View rowView, ViewGroup parent) {
Container container = (Container) getGroup(groupPosition);
if (rowView == null) {
rowView = inflater.inflate(R.layout.item_container, null);
}
TextView containerName = (TextView) rowView.findViewById(R.id.container_name);
containerName.setText(container.name);
notesCounter = (TextView) rowView.findViewById(R.id.notes_counter);
notesCounter.setText(getChildrenCount(groupPosition) + "");
final TextView nt = notesCounter;
notesCounter.post(new Runnable() {
@Override
public void run() {
// nt.getHeight() - return 67 - good!
notesCounter.setWidth(nt.getHeight()); // I WANT REDRAW IT AND SEE EQUAL CIRCLE!
//notesCounter will set width after swipe ExpandableListView and "hide and then appear view"
}
});
Util.loadFont(context, containerName, FONT.GothamExtraLight);
Util.loadFont(context, notesCounter, FONT.GothamExtraLight);
return rowView;
}
见下文:
new Handler().post(new Runnable() {
@Override
public void run() {
notesCounter.setWidth(notesCounter.getHeight());
}
});
您好,您可以在TextView上调用invalidate()。它对我不起作用。
notescenter.requestLayout()
?它的工作原理与我的代码相同。第三个收割台画得很好,但第一个和第二个收割台画得不好。这是因为在第一次和第二次头球抽签后,可运行的后测高度。我需要刷新它们,但如何刷新?