我有不同的布局.一些由xml创建.其他一些人通过代码进行恐慌.当我在xml上时,我可以使用"wrap_content"值设置宽度或高度.如何以相同的方式得到相同的结果?这是我的dinamic TextView的片段.我需要删除"final int width = 440;" 并得到"wrap_content"的相同值.怎么样?
final int width = 440; final int height = textViewHeight; final int top = getNewTop(height); FrameLayout.LayoutParams layoutParams; layoutParams = getLayoutParams(width, height, top); TextView textView; textView = new TextView(_registerNewMealActivity); textView.setText(text); textView.setLayoutParams(layoutParams); _frameLayout.addView(textView);
SilentKiller.. 6
您可以使用 :
textView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, height));