使用百分比布局,运行之后GridView的Item项不显示
GridView所在的XML文件代码如下:
<android.support.percent.PercentRelativeLayout 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" >
<com.example.ui.VerticalScrollView
android:id="@+id/HomePage_sv"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_heightPercent="100%"
android:fillViewport="true" >
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_heightPercent="100%"
android:background="#e2e2e2" >
<android.support.v4.view.ViewPager
android:id="@+id/BannerPage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#ffffff" >
</android.support.v4.view.ViewPager>
<GridView
android:id="@+id/gv_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/BannerPage"
android:layout_marginBottom="10dp"
android:background="#ffffff"
android:horizontalSpacing="20dp"
android:listSelector="@android:color/transparent"
android:numColumns="4"
android:paddingBottom="10dp"
android:scrollbars="none" >
</GridView>
</android.support.percent.PercentRelativeLayout>
</com.example.ui.VerticalScrollView>
</android.support.percent.PercentRelativeLayout>
GridView Item项布局:
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="100dp"
android:layout_height="100dp" >
<ImageView
android:id="@+id/gvNavigation_head"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
app:layout_heightPercent="48%h"
app:layout_widthPercent="48%w"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/gvNavigation_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/gvNavigation_head"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="超市"
android:textColor="#000000"
android:textSize="12sp" />
</android.support.percent.PercentRelativeLayout>
这个百分比布局使用的是CSDN张鸿洋大神分享的源码,直接在TextView、 Button上使用百分比属性都没问题,但是只要遇到ListView、GridView的Item布局时,运行之后就显示不出来Item的布局。
求大神指点