我有一個GridView
,我通過代碼填充,問題是最後一行不完全可見。我不知道爲什麼發生這種情況時,Activity
的佈局很簡單:GridView切斷最後一行
<?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">
<GridView
android:id="@+id/sectionGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:horizontalSpacing="0dp"
android:numColumns="1"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp">
</GridView>
</LinearLayout>
並且佈局該行如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:pew="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white" >
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:id="@+id/sectionImage"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/sectionImage"
android:layout_alignLeft="@+id/sectionImage"
android:layout_alignStart="@+id/sectionImage"
android:background="@drawable/bg_section_row"
android:layout_alignBottom="@+id/sectionTitle"
android:layout_alignRight="@+id/sectionImage"
android:layout_alignEnd="@+id/sectionImage"
android:id="@+id/sectionBgView"></RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="@color/white"
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1"
android:padding="10dp"
android:layout_alignBottom="@+id/sectionImage"
android:layout_alignLeft="@+id/sectionImage"
android:layout_alignStart="@+id/sectionImage"
android:layout_alignRight="@+id/sectionImage"
android:layout_alignEnd="@+id/sectionImage"
android:id="@+id/sectionTitle"/>
</RelativeLayout>
</LinearLayout>
我不知道,如果它可能是相關的,但目前我使用以下主題:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
佈局有什麼問題?我是否缺少GridView
的任何財產?
在GridView控件集填充....機器人:paddingBottom來= 「20dp」 – sasikumar
@sasikumar我知道,增加填充的作品,但我覺得這是非常hackish的,它不是我想要使用的解決方案 – Signo
@Signo您是指當您在'Grid View'中加載動態數據時,它不顯示最後一行? –