Question

How can I align the height of last row where I have ratingBar? As you can see the height is larger than the other rows. I tried making marginTop/paddingTop=0, but nothing is working. Is it because I used height=0 and weight = 1 for all rows?

Thanks

enter image description here

CODE:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:background="@drawable/border"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        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=".AddEntry" >

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <TableRow
        android:id="@+id/tr14"
        android:padding="2.5dp"
        android:background="@color/col2"
        android:gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1" >
        <TextView
            android:id="@+id/l_comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/comment" />

        <EditText
            android:id="@+id/comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:background="@android:color/transparent"
            android:hint="@string/definputtext2" />

    </TableRow>

    <TableRow
        android:id="@+id/tr14a"
        android:padding="2.5dp"
        android:background="@color/col1"
        android:gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1" >
        <TextView
            android:id="@+id/lab_isdn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/isdn" />

        <EditText
            android:id="@+id/isdn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:background="@android:color/transparent"
            android:hint="@string/definputtext2" />
    </TableRow>

    <TableRow
        android:id="@+id/tr15"
        android:paddingLeft="2.5dp"
        android:background="@color/col2"
        android:gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/lab_rating"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:text="@string/rating" />

        <RatingBar
            android:id="@+id/rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:stepSize="1"
            android:rating="1" />

        <TextView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="" />
    </TableRow>
</TableLayout>
</ScrollView>
Was it helpful?

Solution

Use this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="#ff0000"
     android:fillViewport="true"
     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=".AddEntry" >

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TableRow
        android:id="@+id/tr14"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#f0f0f0"
        android:gravity="center_vertical"
        android:padding="2.5dp" >

        <TextView
            android:id="@+id/l_comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Comment" />

        <EditText
            android:id="@+id/comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:textSize="14sp" />
    </TableRow>

    <TableRow
        android:id="@+id/tr14a"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#c0c0c0"
        android:gravity="center_vertical"
        android:padding="2.5dp" >

        <TextView
            android:id="@+id/lab_isdn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ISDN" />

        <EditText
            android:id="@+id/isdn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:textSize="14sp" />
    </TableRow>

    <TableRow
        android:id="@+id/tr15"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="0.7"
        android:background="#f0f0f0"
        android:gravity="center_vertical"
        android:paddingLeft="2.5dp" >

        <TextView
            android:id="@+id/lab_rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Rating" />

        <RatingBar
            android:id="@+id/rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:rating="1"
            android:stepSize="1" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="" />
    </TableRow>
 </TableLayout>

</ScrollView>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top