I have two TextView in a RelativeLayout. How to set the TextViews if I want those always (different screen resolution for example 540x960) the width of each TextView is the 50 percent of the full UI width? I would set size of both TextView to always 50 percent of full width of UI. Need to stretching of TextViews on different screen resolutions. How can I do this?
Whenever split some view like (Button , Text View) in equally in Horizontal / Vertical
android:weight Sum / android:layout_weight Technique use...
Must remember one thing these technique must support in Linear Layout only but here you want to use Relative Layout so that simply put your Linear Layout inside Relative Layout ..
Must Follow These Rules :
1> set android:weight Sum into your Linear Layout
2> set android:layout_width each child View inside "0dp"
3> set android:layout_weight each child View depend upon how many child view & android:weight Sum(e.g: android:weight Sum = "2" & two child view then layout_weight="1" , layout_weight="1")
Ex:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="child View 1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="child View 2"/>
</LinearLayout>
</RelativeLayout>
if Layout Orientation is Vertical then only set android:layout_height is "0dp" instead of android:layout_width
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With