如何在android中的布局中自定义可扩展列表?

时间:2014-04-09 06:07:06

标签: android android-linearlayout fullscreen expandablelistview

我在线性布局中遇到有关可扩展List的问题。我有一个我想要展示的XML 1.标题。 2.单击该标题时,可以展开预定义列表并从该列表中进行选择

但主要的问题是,当我在线性布局中添加页脚图像时,它会在标题下面。并留下一个巨大的空白空间。但是当我通过单击列表展开列表时,页脚仍然保留在最后,屏幕后面没有留空空间。

我希望页脚始终位于屏幕底部,不留任何空白区域,以便整个屏幕都被线性布局覆盖。

请帮帮我们!我很乖。

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:id="@+id/sc1">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingRight="7dip"
    android:paddingLeft="7dip"
    android:paddingTop="5dip"
    android:background="#224782"
    android:orientation="vertical" 
    android:id = "@+id/l1">

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/mybutton"
    android:padding="5dip"
    android:layout_marginBottom="7dip"
    android:orientation="horizontal" >  


    <TextView
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:onClick="openMinimized"
        android:textColor="#ffffff"
        android:shadowColor="#7F000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:layout_weight=".7"
        android:paddingLeft="15dip"
        android:textSize="28dip"
        android:text="@string/start" />

    <ToggleButton 
        android:id="@+id/togglebutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/bgtoggle"
        android:button="@null"
        android:textOff=""
        android:textOn=""
        android:layout_gravity="center"/>


    </LinearLayout>

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:padding="5dip"
    android:layout_marginBottom="7dip"
    android:orientation="vertical" >

        <TextView
        android:id="@+id/txtBoot"
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:gravity="center"
        android:background="@layout/mybutton"
        android:text="@string/sob"
        android:shadowColor="#7F000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:textColor="#FFFAFA"
        android:textSize="24dip" />

    <LinearLayout
        android:id="@+id/lboot"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@layout/layout"
        android:layout_marginBottom="5dip"
        android:clickable="true"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/txtCheck"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left|center_vertical"
            android:text="Always start the Monitoring on Boot"
            android:layout_weight=".001"
            android:textColor="#ffffff"
            android:layout_marginLeft="2dip"
            android:textSize="16dip" />

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_toRightOf="@+id/txtCheck"
            android:layout_width="match_parent"
            android:layout_height="40dip"
            android:checked="true"
            android:button="@null"
            android:drawableRight="@drawable/select_"
            android:layout_marginLeft="8dip"
            android:paddingLeft="10dip"
            android:layout_weight=".999"
            android:enabled="true"
            android:text="" />
    </LinearLayout>

    <TextView
        android:id="@+id/txtSpeed"
        android:layout_width="fill_parent"
        android:layout_height="50dip"
        android:background="@layout/mybutton"
        android:textColor="#FFFAFA"
        android:gravity="center"
        android:shadowColor="#7F000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:drawableRight= "@drawable/arrow"
        android:textAlignment="center"
        android:text="@string/speed" 
        android:textSize="24dip"/>
    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:orientation="vertical" >

    <RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:visibility="gone"
    android:id="@+id/radio_group_speed">

    <RadioButton
        android:id="@+id/radioButton18"
        android:layout_width="match_parent"
        android:layout_height="40dip"        
        android:gravity="left|center_vertical"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:textSize="16dip" 
        android:onClick="onRadioButtonClicked"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout_green"
        android:text="Speed in MB/s"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioButton16"
        android:layout_width="match_parent"
        android:layout_height="40dip"        
        android:gravity="left|center_vertical"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:textSize="16dip" 
        android:onClick="onRadioButtonClicked"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout"
        android:text="Speed in Mb/s"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioButton1"
        android:layout_width="match_parent"
        android:layout_height="40dip"        
        android:gravity="left|center_vertical"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:textSize="16dip" 
        android:onClick="onRadioButtonClicked"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout_green"
        android:text="Speed in KB/s"
        android:textAlignment="textStart"/>



    <RadioButton
        android:id="@+id/radioButton2"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Speed in Kb/s"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:drawableRight="@drawable/white"
        android:clickable="true"
        android:background="@layout/radio_layout"
        android:focusable="true"
        android:textSize="16dip" />


    <RadioButton
        android:id="@+id/radioButton19"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Speed in Combo (KB/s and MB/s)"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:background="@layout/radio_layout_green"
        android:drawableRight="@drawable/white"
        android:clickable="true"
        android:focusable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioButton17"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Speed in Combo (Kb/s and Mb/s)"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:drawableRight="@drawable/white"
        android:clickable="true"
        android:checked="true"
        android:background="@layout/radio_layout"
        android:focusable="true"
        android:textSize="16dip" />

    </RadioGroup>
    </LinearLayout>
    </LinearLayout>

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:padding="5dip"
    android:layout_marginBottom="7dip"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/txtSize"
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:gravity="center"
        android:shadowColor="#7F000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:layout_marginBottom="5dip"
        android:textColor="#FFFAFA"
        android:drawableRight= "@drawable/arrow"
        android:text="@string/display" 
        android:background="@layout/mybutton"
        android:textSize="24dip"/>

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:orientation="vertical" >

    <RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="left"
    android:visibility="gone"
    android:id="@+id/radio_group_size">

    <RadioButton
        android:id="@+id/radio10"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="10pt" 
        android:textSize="16dip"
        android:textColor="#ffffff"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:clickable="true"
        android:background="@layout/radio_layout_green"
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:checked="true"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radio11"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="11pt"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:background="@layout/radio_layout"
        android:clickable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radio12"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="12pt"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:clickable="true"
        android:background="@layout/radio_layout_green"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radio13"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="13pt"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:background="@layout/radio_layout"
        android:clickable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radio14"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="14pt"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout_green"
        android:onClick="onRadioButtonClicked"
        android:clickable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radio15"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="15pt"
        android:background="@layout/radio_layout"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:clickable="true"
        android:textSize="16dip" />

    </RadioGroup>
    </LinearLayout>

    <TextView
        android:id="@+id/txtColor"
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:gravity="center"
        android:textColor="#FFFAFA"
        android:shadowColor="#7F000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:drawableRight= "@drawable/arrow"
        android:background="@layout/mybutton"
        android:text="@string/color" 
        android:textSize="24dip"/>

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:orientation="vertical" >

    <RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:visibility="gone"
    android:id="@+id/radio_group_color">

    <RadioButton
        android:id="@+id/radioWhite"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="White" 
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:layout_gravity="right"
        android:textColor="#ffffff"
        android:textSize="16dip"
        android:background="@layout/radio_layout_green"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioYellow"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Yellow" 
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:layout_gravity="right"
        android:textColor="#ffffff"
        android:textSize="16dip"
        android:background="@layout/radio_layout"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioAquamarine"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Aquamarine" 
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:layout_gravity="right"
        android:textColor="#ffffff"
        android:textSize="16dip"
        android:background="@layout/radio_layout_green"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioAzure"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Azure" 
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:layout_gravity="right"
        android:textColor="#ffffff"
        android:textSize="16dip"
        android:background="@layout/radio_layout"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioBlack"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Black"
        android:onClick="onRadioButtonClicked"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:textAlignment="center"
        android:layout_gravity="right"
        android:clickable="true"
        android:background="@layout/radio_layout_green"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioBlue"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Blue"
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:layout_gravity="right"
        android:background="@layout/radio_layout"
        android:clickable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioRed"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:gravity="left|center_vertical"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:text="Red"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:layout_gravity="right"
        android:background="@layout/radio_layout_green"
        android:clickable="true"
        android:textSize="16dip" />


    <RadioButton
        android:id="@+id/radioJade"
        android:layout_width="match_parent"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:drawableRight="@drawable/white"
        android:layout_height="40dip"
        android:text="Jade"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:layout_gravity="right"
        android:clickable="true"
        android:background="@layout/radio_layout"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioBrightGreen"
        android:layout_width="match_parent"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:drawableRight="@drawable/white"
        android:layout_height="40dip"
        android:text="Bright Green"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:checked="true"
        android:background="@layout/radio_layout_green"
        android:layout_gravity="right"
        android:clickable="true"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioGreen"
        android:layout_width="match_parent"
        android:button="@null"
        android:gravity="left|center_vertical"
        android:drawableRight="@drawable/white"
        android:layout_height="40dip"
        android:text="Green"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout"
        android:onClick="onRadioButtonClicked"
        android:layout_gravity="right"
        android:clickable="true"
        android:textSize="16dip" />

    </RadioGroup>
    </LinearLayout>
    </LinearLayout>


    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/layout"
    android:padding="5dip"
    android:layout_marginBottom="7dip"
    android:orientation="vertical" >

        <TextView
        android:id="@+id/textPosition"
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:gravity="center"
        android:shadowColor="#002E63"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="6"
        android:text="@string/position" 
        android:drawableRight= "@drawable/arrow"
        android:textColor="#FFFAFA"
        android:background="@layout/mybutton"
        android:textSize="24dip"/>

    <RadioGroup
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:visibility="gone"
    android:id="@+id/radio_group_position">

    <RadioButton
        android:id="@+id/radioTopRight"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Top Right Corner" 
        android:gravity="left|center_vertical"
        android:textColor="#ffffff"
        android:onClick="onRadioButtonClicked"
        android:button="@null"
        android:drawableRight="@drawable/white"
        android:textSize="16dip"
        android:checked="true"
        android:background="@layout/radio_layout_green"
        android:textAlignment="textStart"/>

    <RadioButton
        android:id="@+id/radioTopLeft"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:gravity="left|center_vertical"
        android:text="Top Left Corner"
        android:textColor="#ffffff"
        android:button="@null"
        android:onClick="onRadioButtonClicked"
        android:drawableRight="@drawable/white"
        android:clickable="true"
        android:background="@layout/radio_layout"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioBottomRight"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Bottom Right Corner"
        android:gravity="left|center_vertical"
        android:clickable="true"
        android:button="@null"
        android:onClick="onRadioButtonClicked"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout_green"
        android:drawableRight="@drawable/white"
        android:textSize="16dip" />

    <RadioButton
        android:id="@+id/radioBottomLeft"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:text="Bottom Left Corner"
        android:gravity="left|center_vertical"
        android:clickable="true"
        android:button="@null"
        android:onClick="onRadioButtonClicked"
        android:textColor="#ffffff"
        android:background="@layout/radio_layout"
        android:drawableRight="@drawable/white"
        android:textSize="16dip" />

    </RadioGroup>
    </LinearLayout>

     <LinearLayout
            android:id="@+id/rlbtm"
            android:layout_width="wrap_content"
            android:layout_height="0dip"
            android:background="@layout/layout"
            android:layout_weight="1"
            android:gravity="center|bottom"
            android:layout_marginBottom="7dip"
            android:orientation="horizontal" >


         <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center"
            android:src="@drawable/my_logo_1" />

    </LinearLayout>

</LinearLayout>

</LinearLayout>
</ScrollView>

1 个答案:

答案 0 :(得分:0)

如果您认为布局设计中存在问题,请使用“重量”,它可以解决您的问题。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
     android:weightSum="5" >

    <TextView
        android:id="@+id/home"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        />

    <TextView
        android:id="@+id/home1"
       android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/home2"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <TextView
        android:id="@+id/home3"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <ImageView
        android:id="@+id/home4"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
    </LinearLayout>