Question

In my xml layout file, I have a ScrollView. Before I was using weight to seperate TextViews within each TableRow, but that did not satisfy my needs so I decided to use columns in a TableLayout.

My problem lies when I try to apply padding to the ScrollView or the "Container" RelativeLayout, some text gets cut off. If I apply to any child of the ScrollView, it does not show the very bottom of the TableLayout. The closest I got to what I want is when I applied padding to just the TableRows within the TableLayout, but the "Build Version" text gets cut off horizontally (see screenshot below). Other than that it would be satisfactory.

layout.xml

<RelativeLayout 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" >

<ScrollView
    android:id="@+id/svMain"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/adMainBanner"
    android:layout_alignParentTop="true"
    android:fillViewport="true" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <!-- Build -->

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:gravity="center_horizontal"
            android:text="@string/build"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/manufacturer" />

            <TextView
                android:id="@+id/tvManufacturer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/model" />

            <TextView
                android:id="@+id/tvModel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/hardware" />

            <TextView
                android:id="@+id/tvHardware"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/board" />

            <TextView
                android:id="@+id/tvBoard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/bootloader" />

            <TextView
                android:id="@+id/tvBootLoader"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/device" />

            <TextView
                android:id="@+id/tvDevice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/brand" />

            <TextView
                android:id="@+id/tvBrand"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/android_version" />

            <TextView
                android:id="@+id/tvAndroidVersion"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/build_version" />

            <TextView
                android:id="@+id/tvBuildVersion"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <!-- Service / Carrier -->

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="15dp"
            android:gravity="center_horizontal"
            android:text="@string/carrier_service"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/carrier" />

            <TextView
                android:id="@+id/tvCarrier"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/phone_number" />

            <TextView
                android:id="@+id/tvPhoneNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/service_mode" />

            <TextView
                android:id="@+id/tvServiceMode"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <!-- Network -->

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="15dp"
            android:gravity="center_horizontal"
            android:text="@string/network"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/phone_type" />

            <TextView
                android:id="@+id/tvPhoneType"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/network_type" />

            <TextView
                android:id="@+id/tvNetworkType"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <TableRow android:layout_width="match_parent" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:text="@string/baseband" />

            <TextView
                android:id="@+id/tvBaseBand"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="1"
                android:text="text" />
        </TableRow>

        <!-- CPU -->

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="15dp"
            android:gravity="center_horizontal"
            android:text="@string/cpu_info"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvCpuInfo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:text="text" />

        <!-- Ram -->
        <!-- If I apply padding/margin to any container layout,
             this gets cut off(does not show in scrollview)-->

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="15dp"
            android:gravity="center_horizontal"
            android:text="@string/ram_info"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvRamInfo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:text="text" />
    </TableLayout>
</ScrollView>

<com.google.ads.AdView
    xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adMainBanner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    googleads:adSize="SMART_BANNER"
    googleads:adUnitId="@string/admob_banner_id"
    googleads:loadAdOnCreate="true" />

</RelativeLayout>

ScreenShots

How It looks without any padding or margin, Build Version is cut off: How It looks without any padding or margin, Build Version is cut off

And this is the whole Build Version: This is the whole Build Version

Why won't the Build Version text wrap to a new line? After I acheive that, how should I go about applying padding/margin to my whole layout file without borking something inside of the ScrollView? Any Help please, it is greatly appreciated :)

Was it helpful?

Solution

maybe because it doesn't contain any spaces. Try with:

android:singleLine="false"

or

android:ems="30" // or whatever number of characters you want per line
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top