Divide a Screen Into Equally With Two TextView

209 views Asked by At

In my android layout have two textview. Each in different table row. I want to divide these row equally. The first textview is a GCM based text and second is harcoded. The row should be divided equally not depending on the size of the text so i have put scrollview as well and i need it.

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:background="@drawable/border"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LiveMsg" >


<TableRow
    android:id="@+id/tableRow1"
   android:layout_height = "100dp"
    android:layout_weight = "1"
    android:paddingBottom="20dip"
    android:gravity="center" >


<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="0.97"
    android:id="@+id/scrollview1"
    android:scrollbars="vertical" >

<TextView
    android:id="@+id/lblMessage"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#FFFFFF"
    android:textSize="30sp"
    android:text="" />
</ScrollView>
</TableRow>

<TableRow
    android:id="@+id/tableRow2"
   android:layout_height = "100dp"
    android:layout_weight = "1"
    android:paddingBottom="20dip"
    android:gravity="center"  >


<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="0.97"
    android:id="@+id/scrollview2"
    android:scrollbars="vertical" >

<TextView
    android:id="@+id/tableRow5"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#FFFF00"
    android:textSize="20sp"
    android:text="LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE....LONG TEXT GOES HERE.... " />
</ScrollView>
</TableRow>

It should work on all screen size.how can i do that?

1

There are 1 answers

0
Harin On

Replace your TableRow like this:

<TableRow
  android:id="@+id/tableRow2"
  android:layout_width = "match_parent"
  android:layout_height = "match_parent"
  android:layout_weight = "1"
  android:paddingBottom="20dip"
  android:gravity="center">

also remove weights from scroll view. You can also use only two scroll views with same trick as above.