1. TextView control is a text representation control, the main function is to show the user the content of the text, it is not editable, such as setting the title; The EditText control is the edit text control, the main function is to let the user enter the text content, it can be edited.
Each control has its own properties, and it can achieve different effects by selecting different properties and giving them values.
2. When the Layout_width property value is set to Wrap_content, only enough space is available to depict itself, as well as additional space. The Layout_weight property value for additional space allocation.
If layout_width= "0DP", only the Layout_weight property value is considered.
<linearlayout
android:orientation= "Horizontal"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:layout_marginleft= "16DP"
android:layout_marginright= "16DP" >
<button
android:text= "button"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:id= "@+id/crime_date"
android:layout_weight= "1"
/>
<checkbox
Android:id= "@+id/crime_solved"
android:text= "@string/crime_solved_label"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_marginleft= "16DP"
android:layout_marginright= "16DP"
android:layout_weight= "1"/>
</LinearLayout>
such as code: LinearLayout has two controls, a Button and a checkbox.
The first step is to view the Layout_width property value (view Layout_height in the vertical direction). Because when set to Wrap_content, the space available is only enough to depict itself, and there is extra space.
The second step LinearLayout additional space allocations based on the attribute values of the layout_weight. Two sub-component property values are the same as 1. Because the same size of the extra space is evenly divided. If the layout_weight of the button is set to a value of 2, 2/3 of the extra space will be obtained.
The checkbox component obtains the remaining 1/3.
Layout TextView and EditText differences, layout_width and lay_weight differences--android Studio