多行文本框后的Android布局滚动问题

时间:2018-09-03 02:17:02

标签: android xml layout

在下面的xml布局中,我得到以下内容,当我向问题后续文本视图添加几行内容时,最后一张图像将发生。

然后,我将不再能够滚动到屏幕底部的所有按钮。

有人知道我如何解决此布局吗?

是否有更好的方法来创建此布局?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              xmlns:card_view="http://schemas.android.com/tools"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:paddingTop="12dp"
              android:paddingLeft="8dp"
              android:paddingRight="8dp">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

        <com.github.captain_miao.optroundcardview.OptRoundCardView
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:optRoundCardCornerRadius="5dp"
            app:optRoundCardLeftBottomCorner="false"
            app:optRoundCardRightBottomCorner="false"
            app:optRoundCardBottomEdges="false"
            card_view:cardUseCompatPadding="true"
            card_view:cardElevation="5dp"
            android:layout_marginBottom="7dp"
            >

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3"

            >

            <TableRow>
                <TextView
                    android:id="@+id/lblDate"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="Date:"
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:textSize="14dp"
                    />


                <TextView
                    android:id="@+id/txtDate"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:textSize="14dp"
                    android:text="" />

                <android.support.v7.widget.AppCompatButton
                    android:id="@+id/btnChangeDate"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:background="@drawable/button_bg_silver"
                    android:textSize="12dp"
                    android:text="Change" />


            </TableRow>

          </TableLayout>
        </com.github.captain_miao.optroundcardview.OptRoundCardView>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

        <com.github.captain_miao.optroundcardview.OptRoundCardView
            android:id="@+id/card_view2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:optRoundCardCornerRadius="5dp"
            app:optRoundCardLeftBottomCorner="false"
            app:optRoundCardRightBottomCorner="false"
            app:optRoundCardBottomEdges="false"
            card_view:cardUseCompatPadding="true"
            card_view:cardElevation="5dp"
            android:layout_marginBottom="7dp"
            >

            <TableLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:weightSum="4"

                >

            <TableRow>

                <TextView
                    android:id="@+id/lblStartKm"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="Start KM:"
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:textSize="14dp"
                    />

                <EditText
                    android:id="@+id/txtStartKm"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:inputType="number"
                    android:textSize="14dp"
                    />

                <TextView
                    android:id="@+id/lblEndKm"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="End KM:"
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:textSize="14dp"
                    />

                <EditText
                    android:id="@+id/txtEndKm"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:layout_weight="1"
                    android:textColor="@color/black"
                    android:layout_margin="5dp"
                    android:inputType="number"
                    android:textSize="14dp"
                    />


            </TableRow>

                <TableRow>

                    <TextView
                        android:id="@+id/lblTruckRego"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text="Truck Rego:"
                        android:layout_weight="1"
                        android:textColor="@color/black"
                        android:layout_margin="5dp"
                        android:textSize="14dp"
                        />

                    <EditText
                        android:id="@+id/txtTruckRego"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text=""
                        android:layout_weight="1"
                        android:textColor="@color/black"
                        android:layout_margin="5dp"
                        android:textSize="14dp"
                        />



                    <View
                        android:id="@+id/viewSpace"
                        android:layout_width="0dp"
                        android:layout_height="2dp"
                        android:layout_weight="2"
                        />

                </TableRow>


            </TableLayout>


        </com.github.captain_miao.optroundcardview.OptRoundCardView>

    </LinearLayout>


    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3"
        android:layout_marginTop="10dp">

        <android.support.v7.widget.CardView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

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

                <TableRow
                    android:layout_width="fill_parent"
                    android:paddingBottom="5dp">
                    <CheckBox
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Are all the tyres in a roadworthy condition?"
                        android:textColor="@color/black"
                        android:id="@+id/chkTyresSafe"
                        android:theme="@style/MyCheckBox"
                        android:layout_weight="1"
                        android:checked="false"
                        />

                </TableRow>

                <TableRow
                    android:layout_width="fill_parent"
                    android:paddingBottom="5dp">
                    <CheckBox
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Are all the lights working?"
                        android:textColor="@color/black"
                        android:id="@+id/chkAllLightsWorking"
                        android:theme="@style/MyCheckBox"
                        android:layout_weight="1"
                        android:checked="false"
                        />

                </TableRow>

                <TableRow
                    android:layout_width="fill_parent"
                    android:paddingBottom="5dp">
                    <CheckBox
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Does the vehicle require any maintenance?"
                        android:textColor="@color/black"
                        android:id="@+id/chkTruckIsSafeToDrive"
                        android:theme="@style/MyCheckBox"
                        android:layout_weight="1"
                        android:checked="false"
                        />

                </TableRow>

            </TableLayout>

        </android.support.v7.widget.CardView>

    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

        <com.github.captain_miao.optroundcardview.OptRoundCardView
            android:id="@+id/card_view3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:optRoundCardCornerRadius="5dp"
            app:optRoundCardLeftBottomCorner="false"
            app:optRoundCardRightBottomCorner="false"
            app:optRoundCardBottomEdges="false"
            card_view:cardUseCompatPadding="true"
            card_view:cardElevation="5dp"
            android:layout_marginBottom="7dp"
            >


        </com.github.captain_miao.optroundcardview.OptRoundCardView>

    </LinearLayout>


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:padding="5dp"
        >

        <TableLayout
            android:id="@+id/tblQuestion1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="1"

            >

            <TableRow>
                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text="Is there any Issues from todays deliveries that need further follow up?"
                    android:layout_weight="3"
                    android:textColor="@color/greenText"
                    />
            </TableRow>

            <TableRow>
                <EditText
                    android:id="@+id/txtFurtherFollowUpNote"
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text=""
                    android:layout_weight="1"
                    />
            </TableRow>

        </TableLayout>

    </LinearLayout>

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="3"
        >


        <TableRow>
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/btnLogBook"
                android:layout_width="0dp"
                android:layout_weight="1.5"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:layout_margin="5dp"
                android:background="@drawable/button_bg_orange"
                android:text="Log Book" />

            <android.support.v7.widget.AppCompatButton
                android:id="@+id/btnFuelReceipts"
                android:layout_width="0dp"
                android:layout_weight="1.5"
                android:layout_margin="5dp"
                android:layout_height="wrap_content"
                android:background="@drawable/button_bg_orange"
                android:text="Fuel Receipts" />

        </TableRow>


        <TableRow>
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/btnViewCapturedImages"
                android:layout_width="0dp"
                android:layout_weight="2"
                android:layout_margin="5dp"
                android:layout_height="wrap_content"
                android:background="@drawable/button_bg_silver"
                android:text="View Captured Images"/>
        </TableRow>


        <TableRow>
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/btnSubmit"
                android:layout_width="0dp"
                android:layout_weight="2"
                android:layout_margin="5dp"
                android:layout_height="wrap_content"
                android:background="@drawable/save_btn_bg"
                android:text="Submit"/>
        </TableRow>

    </TableLayout>



</LinearLayout>

Starting Layout

Resulting Layout

0 个答案:

没有答案