-1

I have the layout below. It is dynamically loaded but sometimes, if the button text is too big, the last button btCapital9 is only half displayed.

Only this button, and only in some cases. Any ideas why?

Screen shot test

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    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="ro.giohnnysoftware.mondo.PlayVsTime"
    android:background="@drawable/worldmap">
    <RelativeLayout
        android:id="@+id/VPlayVsTimeFooter"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true" />
    <RelativeLayout
        android:id="@+id/VMainContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:screenOrientation="portrait"
        tools:context=".MainActivity"
        android:layout_above="@+id/VPlayVsTimeFooter"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        android:touchscreenBlocksFocus="false">
        <TextView
            android:id="@+id/tvTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="> MONDO &lt;"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textStyle="bold"
            android:textSize="45dp"
            android:textColor="#ff0000" />
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/drapel"
        android:layout_below="@+id/tvTitle"
        android:layout_alignRight="@+id/tvTitle" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/tvTime"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:textSize="@dimen/btTextSize"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true" />

        <Button
            android:id="@+id/btStartVsTime"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Start"
            android:nestedScrollingEnabled="false"
            android:background="@drawable/buttonshape"
            android:textSize="@dimen/btTextSize"
            android:textColor="@color/colorMondo1"
            android:textStyle="bold"
            android:layout_marginLeft="@dimen/btLeftMargin"
            android:layout_marginRight="@dimen/btRightMargin"
            android:layout_alignParentBottom="true"
            android:onClick="StartVsTime"
            android:visibility="invisible"
            android:layout_marginBottom="5dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Country name"
            android:id="@+id/tvCountry"
            android:textSize="@dimen/tvCountryName"
            android:textColor="@android:color/white"
            android:layout_centerHorizontal="true"
            android:layout_alignLeft="@+id/tvTitle"
            android:layout_below="@+id/tvTitle"
            android:layout_marginLeft="15dp"
            android:visibility="invisible"
            android:layout_marginTop="15dp"
            android:shadowColor="@color/colorMondo1"
            android:shadowRadius="25.0"
            android:shadowDx="1.0"
            android:shadowDy="1.0"
            android:singleLine="false"
            android:textAllCaps="true"/>

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentStart="true"
            android:layout_alignParentEnd="true"
            android:layout_below="@+id/tvCountry"
            android:layout_marginTop="20dp"
            android:visibility="invisible"
            android:id="@+id/tbAnswers">

            <TableRow
                android:weightSum="2">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital0"
                    android:layout_column="0"
                    android:layout_weight="1"
                    android:background="@drawable/buttonplay"
                    android:layout_marginRight="2dp"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital1"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:background="@drawable/buttonplay"
                    android:layout_marginLeft="2dp"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />
            </TableRow>

            <TableRow
                android:weightSum="2">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital2"
                    android:layout_column="0"
                    android:layout_weight="1"
                    android:background="@drawable/buttonplay"
                    android:layout_marginRight="2dp"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital3"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:background="@drawable/buttonplay"
                    android:layout_marginLeft="2dp"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />
            </TableRow>

            <TableRow
                android:weightSum="2">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital4"
                    android:layout_column="0"
                    android:layout_weight="1"
                    android:layout_marginRight="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital5"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:layout_marginLeft="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />
            </TableRow>

            <TableRow
                android:weightSum="2">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital6"
                    android:layout_column="0"
                    android:layout_weight="1"
                    android:layout_marginRight="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital7"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:layout_marginLeft="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />
            </TableRow>

            <TableRow
                android:weightSum="2">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="New Button"
                    android:id="@+id/btCapital8"
                    android:layout_column="0"
                    android:layout_weight="1"
                    android:layout_marginRight="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="New Button"
                    android:id="@+id/btCapital9"
                    android:layout_column="1"
                    android:layout_weight="1"
                    android:layout_marginLeft="2dp"
                    android:background="@drawable/buttonplay"
                    android:textColor="@color/colorMondo1"
                    android:textSize="@dimen/btPlayTextSize"
                    android:textAllCaps="false"
                    android:layout_gravity="top"
                    android:layout_marginTop="5dp" />
            </TableRow>
        </TableLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/tvPoints"
            android:textColor="@android:color/white"
            android:textStyle="bold"
            android:textSize="@dimen/btTextSize"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true" />

    </RelativeLayout>
</RelativeLayout>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

0

On the other buttons you have

android:layout_height="match_parent"

On the button in question you have

android:layout_height="wrap_content"

Can I also suggest a LinearLayout?

B... James B.
  • 136
  • 1
  • 8
  • No problem. I do think it may serve you better to use a LinearLayout(horizontal) for each row wrapped in a LinearLayout(vertical). This would allow your view to scale and it would also probably render faster. – B... James B. Apr 10 '16 at 22:15
0

On the other buttons you have

android:layout_height="match_parent"

On the button in question you have

android:layout_height="wrap_content"