LinearLayout - 定位视图

时间:2016-11-28 11:58:16

标签: android-layout android-linearlayout

我有这种布局。

<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/numbers_root"
        android:orientation="vertical"
        android:gravity="top"
        >
        <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/numbersList"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="116dp"
    android:clipToPadding="false"
    tools:layout_height="100dp"
    ></ListView>
        <ExpandableListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/subcategory_expandable"
            >
        </ExpandableListView>

    </LinearLayout>
</RelativeLayout> 

但问题是,尽管父布局中有gravity="top",但ExpandableListView始终以屏幕为中心。我想要的是让它从ListView结束的确切位置开始。知道可能导致这种情况的原因吗? 我应该使用scrollview而不是linearlayout吗?

这是一个清晰的屏幕截图: enter image description here

我希望可扩展列表视图显示在列表视图下方。

1 个答案:

答案 0 :(得分:1)

我认为问题在于function totalfixfees(){ var tffees = 0; var cusid_ele = document.getElementsByClassName('ffeetotal'); //debugger; for (var i = 0; i < cusid_ele.length; i++) { if (!isNaN(parseFloat(cusid_ele[i].innerText)) ) tffees += parseFloat(cusid_ele[i].innerText); } document.getElementById('tffees').innerText = tffees; } function add_row() { var new_ffname = document.getElementById("new_ffname").value; var new_ffamount = document.getElementById("new_ffamount").value; var table = document.getElementById("data_table"); var table_len = (table.rows.length) - 1; var row = table.insertRow(table_len).outerHTML = "<tr id='row" + table_len + "'><td id='ffname_row" + table_len + "'>" + new_ffname + "</td><td class='ffeetotal' id='ffamount_row" + table_len + "'>" + new_ffamount + "</td><td><input type='button' id='edit_button" + table_len + "' value='Edit' class='edit' onclick='edit_row(" + table_len + ")'> <input type='button' id='save_button" + table_len + "' value='Save' class='save' onclick='save_row(" + table_len + ")'> <input type='button' value='Delete' class='delete' onclick='delete_row(" + table_len + ")'></td></tr>"; document.getElementById("new_ffname").value = ""; document.getElementById("new_ffamount").value = ""; } 上的paddingBottom="116dp"正在推动ListView