【问题标题】:Display positioned at the bottom of the list显示在列表底部
【发布时间】:2013-02-06 13:46:25
【问题描述】:

在 Nexus S 和 WildFire 上显示我的 ExpandableHeightGridView 时,activity 视图默认位于 scrollview 的底部。 当我启动应用程序时,ExpandableHeightGridView 具有不同的视图,然后主 layout 自动在底部滚动!!! 有没有人遇到过同样的问题?

这是我的ExpandableHeightGridView

public class ExpandableHeightGridView extends GridView {

    // Attributes
    private boolean mExpanded = true;

    public ExpandableHeightGridView(Context context) {
        super(context);
    }

    public ExpandableHeightGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ExpandableHeightGridView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (isExpanded()) {
            // Calculate entire height by providing a very large height hint.
            // But do not use the highest 2 bits of this integer; those are
            // reserved for the MeasureSpec mode.
            int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, expandSpec);
            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = getMeasuredHeight();
        }
        else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }

    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
    }

    public boolean isExpanded() {
        return mExpanded;
    }
}

我的主要xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/program_showview_padding"
        android:paddingTop="@dimen/program_showview_padding_top">

        <TextView
            android:id="@+id/program_category"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/program_vignette"
            android:layout_alignParentRight="true" />
        <TextView
            android:id="@+id/program_sub_category"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_category"
            android:layout_toRightOf="@id/program_vignette"
            android:layout_alignParentRight="true" />
        <TextView
            android:id="@+id/program_duration"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_sub_category"
            android:layout_toRightOf="@id/program_vignette"
            android:layout_alignParentRight="true" />
        <ImageView
            android:id="@+id/program_csa"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_duration"
            android:layout_toRightOf="@id/program_vignette"/>
        <TextView
            android:id="@+id/program_tweets_count"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_csa"
            android:layout_toRightOf="@id/program_vignette"
            android:layout_alignParentRight="true" />
        <TextView
            android:id="@+id/program_summary_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_vignette"
            android:text="@string/program_showview_summary" />
        <TextView
            android:id="@+id/program_summary"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_summary_label" />
        <TextView
            android:id="@+id/program_casting_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_summary"
            android:text="fffffff" />
        <fr.haploid.widget.ExpandableHeightGridView
            android:id="@+id/program_casting"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/program_casting_label"
            android:numColumns="auto_fit" />
    </RelativeLayout>
</ScrollView>

【问题讨论】:

    标签: android gridview


    【解决方案1】:

    尝试将您的滚动视图设置为不可聚焦。我有同样的问题,这解决了它。

    yourExpandableHeightGridView.setFocusable(false);
    

    android:focusable="false"
    

    在 XML 中。

    【讨论】:

      猜你喜欢
      • 2020-12-11
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 2013-10-24
      • 2014-12-27
      • 2011-03-21
      • 2011-03-08
      • 2019-08-03
      相关资源
      最近更新 更多