2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
 >

<ScrollView
    android:id="@+id/ScrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true" >

     <LinearLayout
         android:id="@+id/MainParent"
         android:layout_width="wrap_content"
         android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="454dp"
        android:layout_gravity="bottom"
        android:layout_marginLeft="20sp"
        android:layout_marginRight="20sp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="80sp"
            android:text="Sim Card Master"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/pumpkinorange"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/simno"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5sp"
            android:text="Sim No"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/darkblue"
            android:textSize="14sp" />

        <EditText
            android:id="@+id/simName"
            android:layout_width="275dp"
            android:layout_height="wrap_content"
            android:selectAllOnFocus="true" >
            <requestFocus />
        </EditText>

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="145dp"
            android:layout_height="wrap_content"
            android:text="Service Provider"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/darkblue"
            android:textSize="14sp" />

        <Spinner
            android:id="@+id/spinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:entries="@array/service_arrays"
            android:prompt="@string/serviceprovid" />

        <TextView
            android:id="@+id/TextView02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100sp"
            android:layout_marginTop="5dp"
            android:text="Unit Master"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/pumpkinorange"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/TextView03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5sp"
            android:text="Unit No"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/darkblue"
            android:textSize="14sp" />

        <EditText
            android:id="@+id/unitNo"
            android:layout_width="275dp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:selectAllOnFocus="true" />

        <TextView
            android:id="@+id/TextView04"
            android:layout_width="145dp"
            android:layout_height="wrap_content"
            android:text="IMEI No"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/darkblue"
            android:textSize="14sp" />

        <EditText
            android:id="@+id/imeiNo"
            android:layout_width="275dp"
            android:layout_height="wrap_content"
            android:ems="10" 
            android:selectAllOnFocus="true"/>

        <TextView
            android:id="@+id/vehicleNo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="80sp"
            android:layout_marginTop="5dp"
            android:gravity="center"
            android:text="Vehicle Master"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/pumpkinorange"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/TextView06"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:text="Vehicle No"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/darkblue"
            android:textSize="14sp" />

        <EditText
            android:id="@+id/vehicleNo"
            android:layout_width="275dp"
            android:layout_height="wrap_content"
            android:ems="10" 
            android:selectAllOnFocus="true"/>

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="34dp"
            android:layout_gravity="center"
            android:text="Save"
            android:textSize="15sp"
            android:textStyle="italic"
            android:typeface="normal" />

        <Button
            android:id="@+id/button2"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:text="Reset"
            android:textSize="15sp"
            android:textStyle="italic"
            android:typeface="normal" />

    </LinearLayout>

     </LinearLayout>
</ScrollView>

</RelativeLayout>

I don't know to correct this error. In xml layout i can see the button, but in the emulator its not visible or button not scrolled. also i want this two button in same line with left and right alignment.

4

2 回答 2

1

您在滚动视图中指定第二个线性布局为

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="454dp"
        android:layout_gravity="bottom"
        android:layout_marginLeft="20sp"
        android:layout_marginRight="20sp"
        android:orientation="vertical" >

改成

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginLeft="20sp"
        android:layout_marginRight="20sp"
        android:orientation="vertical" >

您指定的高度已修复,为什么它不显示...

<LinearLayout 

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_margin="3dp"         
            >

                      <Button 
                android:id="@+id/login_btn"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_weight="0.5"
                android:text="Login"
                />

            <Button 
                android:id="@+id/cancel_btn"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_weight="0.5"
                android:text="Cancel"
                />
            </LinearLayout>
于 2013-08-20T09:03:33.400 回答
0

将 ScrollView 的高度设置为match_parent

<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
于 2013-08-20T08:46:34.403 回答