I would like to set
android:layout_height=”wrap_content“
to some pixels(int) during my application start. This is a textView and the reason behind this is that i want the height of the textView dynamic based on some inputs from my end which will be computed when the onCreate method is called.
Is this possible? if yes any example would be great.
Forgot to add my textView xml looks like this
<TextView
android:id="@+id/sometext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdge="vertical"
android:background="@drawable/dropshadow"
android:scrollbars="vertical"
android:text="Getting data on your slow n/w..."
android:textColor="#ffffff"
/>
Just edit the layout params of the view.
The view will be 50px high in this example.
Note that it’s generally not recommended to use pixel dimensions for layouts due to the many device specs out there. Rather use dp (density independent pixels) instead. You can calculate pixel dimensions from dp values in the following way (50dp to px here):