android - 带有 ListView 的 SwipeRefreshLayout 占用了所有可用空间
问题描述
本来以为不用写到这里的,但是解决不了问题!我有一个ListView
,有wrap_content
,在它下面TabLayout
和ViewPager
。一切正常,layout
当我填充时正确对齐ListView
:
<RelativeLayout 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">
<LinearLayout
android:id="@+id/headerTable"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_modena"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table11"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_saldo"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table12"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_pagar"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table13"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_cobrar"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table14"
android:textColor="#000000"
android:textSize="14sp" />
</LinearLayout>
<ListView
android:id="@+id/listViewTrefi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/headerTable" />
<View
android:id="@+id/divider2"
style="@style/dividerMain"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="@+id/listViewTrefi"
android:alpha="0.5" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
style="@style/SlidingTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/divider2"
app:tabMode="fixed"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance" />
<wales.dahoum.mipyme.NonSwipeableViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/sliding_tabs" />
</RelativeLayout>
但是当我尝试换行时ListView
,占用所有可用空间SwipeRefreshLayout
,layout is
并隐藏它下面的其他视图 -TabLayout
并且ViewPager
:
<RelativeLayout 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">
<LinearLayout
android:id="@+id/headerTable"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_modena"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table11"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_saldo"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table12"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_pagar"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table13"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/text_cobrar"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="0.7"
android:background="@drawable/table_border"
android:gravity="center"
android:text="@string/table14"
android:textColor="#000000"
android:textSize="14sp" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/headerTable">
<ListView
android:id="@+id/listViewTrefi"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
<View
android:id="@+id/divider2"
style="@style/dividerMain"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="@+id/swipe_refresh"
android:alpha="0.5" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
style="@style/SlidingTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/divider2"
app:tabMode="fixed"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance" />
<wales.dahoum.mipyme.NonSwipeableViewPager
android:id="@+id/viewPager"
android:layout_below="@id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
这是正确的(左)和坏的(右)对齐:
你有什么建议来解决这个问题?
解决方案
推荐阅读
- batch-file - ftp.exe 找不到作为环境变量值的文件夹
- swift - Swift:使用闭包添加 2 个数字的程序
- javascript - 过滤数组 (JS)
- matlab - MATLAB - 将不同的数组/矩阵连接到更大的矩阵
- django - 添加带有 label_tag 的 Font Awesome 图标
- docker - 如何并行化 docker run?
- sql-server - 具有两个外键列的 Sql 条件
- node.js - 在终端中运行“npm run dev”后出现空白页
- java - 当我们总是可以在超类中使用泛型方法时,为什么还要使用抽象方法和覆盖呢?
- java - java中移动的JLabel