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>