re-setting a TextView height programmatically

后端 未结 6 1082
甜味超标
甜味超标 2020-12-24 11:20

I want to reset a textView height after I have added it to the main window in the xml file.

inside a RelativeLayout,

  

        
6条回答
  •  时光取名叫无心
    2020-12-24 12:16

    you can dynamically set width and height of textview by

    private TextView mTxtView;
    private int screenWidth, screenHeight;
    Display display = getWindowManager().getDefaultDisplay(); 
        screenWidth = display.getWidth();
        screenHeight = display.getHeight();
    
    
    LayoutParams params = mTxtView.getLayoutParams();
        params.width = screenWidth-30;
        mTxtView.setLayoutParams(params);
    

提交回复
热议问题