2

在 Nexus S 和 WildFire 上显示 my 时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>
4

1 回答 1

3

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

yourExpandableHeightGridView.setFocusable(false);

或者

android:focusable="false"

在 XML 中。

于 2013-05-30T12:59:31.217 回答