相关疑难解决方法(0)

Gridview高度被削减

我正在尝试在gridview中显示8个项目.遗憾的是,gridview高度总是太小,所以它只显示第一行,而第二行的一小部分.

设置android:layout_height="300dp"使它工作.包装content,fill_parent显然不是.

我的网格视图:

<GridView
    android:id="@+id/myId"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:horizontalSpacing="2dp"
    android:isScrollContainer="false"
    android:numColumns="4"
    android:stretchMode="columnWidth"
    android:verticalSpacing="20dp" />
Run Code Online (Sandbox Code Playgroud)

我的物品资源:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:minHeight="?android:attr/listPreferredItemHeight" >

    <ImageView
        android:id="@+id/appItemIcon"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_dialog_info"
        android:scaleType="center" />      

    <TextView
        android:id="@+id/appItemText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="My long application name"
        android:gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这个问题似乎与缺乏垂直空间有关.

我能做什么 ?

android gridview

120
推荐指数
4
解决办法
6万
查看次数

NestedScrollview不会从顶部开始

我在NestedScrollview中有一个Recyclerview ..一切正常,除了一个thig.我在NestedScrollview中有三个视图,前两个是LinearLayout然后是Recyclerview.当我运行我的应用程序时,活动不显示前两个布局,它从Recyclerview的顶部开始.

它如何显示我的布局:

它如何展示我的布局

它的假设如何显示:

它的假设如何显示

我在viewpager下加载这个enite布局,我的viewpager是Coordinator Layout的子代.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/home_layout_background">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <com.daimajia.slider.library.SliderLayout
            android:id="@+id/image_slider"
            android:layout_width="match_parent"
            android:layout_height="@dimen/image_slider_height"
            android:layout_marginTop="@dimen/image_slider_top_margin" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/popular_fragment_side_padding"
        android:layout_marginRight="@dimen/popular_fragment_side_padding"
        android:layout_marginTop="@dimen/popular_fragment_side_padding"
        android:orientation="horizontal"
        android:weightSum="4">

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1">

            <RelativeLayout
                android:id="@+id/free_delivery"
                android:layout_width="76dp"
                android:layout_height="76dp"
                android:layout_centerInParent="true"
                android:background="@color/white">

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true">

                    <ImageView
                        android:id="@+id/btnImageViewFreeDelivery"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="true"
                        android:background="@drawable/icon_free_delivery" />

                    <TextView
                        android:id="@+id/btnTextFreeDelivery"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/btnImageViewFreeDelivery"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="2dp"
                        android:text="@string/free_delivery_txt"
                        android:textColor="@color/popular_fragment_four_btn_txt"
                        android:textSize="@dimen/popular_fragment_four_btn_txt_size" />
                </RelativeLayout>

            </RelativeLayout>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1">

            <RelativeLayout
                android:id="@+id/flash_deals"
                android:layout_width="76dp"
                android:layout_height="76dp" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview nestedscrollview

48
推荐指数
3
解决办法
2万
查看次数

Scrollview没有完全向下滚动

我正在构建一个类似聊天的应用程序,使用滚动视图显示用户输入到屏幕的文本.我正在做的是自动滚动滚动视图,因为更多文本被附加到屏幕上.我正在使用

 ScrollView my_scrollview = (ScrollView) findViewById(R.id.scroller);
 my_scrollview.fullScroll(ScrollView.FOCUS_DOWN);
Run Code Online (Sandbox Code Playgroud)

这似乎有用,虽然由于某种原因,因为键盘通常在屏幕上聊天,当滚动视图向下滚动它并不完全 - 添加的最新文本视图不显示(你必须手动向下滚动到最新一).我该如何解决这个问题?

java android scroll scrollview

12
推荐指数
2
解决办法
7051
查看次数