Я хочу показать TableLayout
ниже Listview
(, где номер динамически добавляется). Раньше я говорил о подобном вопросе, но для меня это не сработало. Я использую android:layout_below
, чтобы установить TableLayout
ниже Listview
, но он по-прежнему не работает, я был бы признателен за то, что я направлял меня на то, как это сделать.TableLayout ниже Listview не отображается
Вот мой код:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clipToPadding="false"
android:divider="@color/list_divider"
android:dividerHeight="10.0sp"
android:listSelector="@drawable/list_row_selector"
android:paddingBottom="100dip"
android:paddingTop="70dip" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/list"
android:layout_weight="1">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Items"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="idvalue_text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Cost"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="idvalue_text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</android.support.design.widget.CoordinatorLayout>
Почему вы предпочитаете использовать 'CoordinatorLayout' вместо' RelativeLayout'? 'layout_below' не работает для' CoordinatorLayout', только для 'RelativeLayout', см. здесь информацию' LayoutParams' для [CoordinatorLayout] (http://developer.android.com/reference/android/support/design/widget/CoordinatorLayout .LayoutParams.html) | [RelativeLayout] (http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html). Кроме того, поможет, если вы предоставите ссылку на вопрос, о котором вы говорите. –
@sept Я изменил координатор влево на относительный макет, а также layout_below не работает – user3923278
Я заметил, что все дочерние представления имеют 'match_parent' /' fill_parent', установленные на их ** ширину ** и ** высоту **, I что «TableLayout» может отображаться, но это не видно, так как «ListView» занимает все пространство? –