IOS dynamically defines the height and iostextview for TextView based on the text content.
Solution:
1. Define a textview and set the constraints of the textview in storyboard.
2. Define the height constraint in the header file: (drag it directly)
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textviewHeightConstraint;
3. After the content is loaded for textview in the implementation file, obtain the text height and assign the value to the constraint:
CGSize sizeThatShouldFitTheContent = [self.shippingAddressTextView sizeThatFits:self.shippingAddressTextView.frame.size]; self.textviewHeightConstraint.constant = sizeThatShouldFitTheContent.height;
Reference link:
Http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content/2487402#2487402
How does android change the height of text view in code? text view is laid out in xml
Activity Definition
Private TextView TV;
In the onCreate function of the Activity
TV = (TextView) findViewById (R. id. TextView01)
Here, R. id. TextView01 is defined in xml
LayoutParams p = TV. getLayoutParams ();
P. height = 100;
TV. setLayoutParams (p );
Android development: how to set the text and background colors of textView statically and dynamically? Beginners do not know what to fill in details
Static is to fill in the attributes in the visualized Graphical Layout.
TextView1.TextColor (text color)
TextView1.Background (background color)
In @ android, all defined color values are automatically displayed.
For example, @ android: color/holo_blue_bright
Dynamic is set color in the program
Import android. graphics. Color;
TextView1.setTextColor (Color. RED );
TextView1.setBackgroundColor (Color. RED );