![](/img/trans.png)
[英]How to make a Button Visible/Gone on scroll listener of gridView in Android
[英]How to make GridView show all component in Android(needless scroll)
這是我的xml文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"
android:background="@android:color/transparent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:background="@android:color/transparent"
android:id="@+id/nested_scrollview"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="@dimen/medium_margin"
android:background="@drawable/button_layout_progress_fragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginRight="@dimen/small_margin"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginBottom="@dimen/small_margin">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="Time spent:"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_marginRight="@dimen/small_margin"/>
<TextView
android:textColor="@android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="2hrs 37 mins" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="@dimen/small_margin"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginBottom="@dimen/small_margin"
>
<TextView
android:textColor="@android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="New words learnt:"
android:textStyle="bold"
android:layout_marginRight="@dimen/small_margin"/>
<TextView
android:textColor="@android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="259 words"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="@dimen/small_margin"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginBottom="@dimen/medium_margin"
>
<TextView
android:textColor="@android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="Word roots learnt:"
android:textStyle="bold"
android:layout_marginRight="@dimen/small_margin"/>
<TextView
android:textColor="@android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="37 words"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/button_layout_progress_fragment"
>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="200dp"
android:layout_width="match_parent"
android:id="@+id/gvBadges"
android:numColumns="3"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:gravity="center"
android:stretchMode="columnWidth"
>
</GridView>
</LinearLayout>
</LinearLayout>
</ScrollView>
我在里面使用了scrollview封面gridview。 而且我只想使用scrollview向下滾動屏幕,所以gridview將顯示其中的所有項目。 我該怎么做? 預先謝謝你!
采用
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
代替
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:background="@android:color/transparent"
android:id="@+id/nested_scrollview">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.