显示位于列表的底部 [英] Display positioned at the bottom of the list
本文介绍了显示位于列表的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显示,当在的Nexus S和野火我的 ExpandableHeightGridView
的活动
视图定位在的底部滚动视图
默认情况下。
当我启动不同的应用来看, ExpandableHeightGridView
然后主布局
底部自动滚动!
没有任何一个面临同样的问题?
下面是我的 ExpandableHeightGridView
:
公共类ExpandableHeightGridView扩展GridView控件{
//属性
私人布尔mExpanded = TRUE;
公共ExpandableHeightGridView(上下文的背景下){
超(上下文);
}
公共ExpandableHeightGridView(上下文的背景下,ATTRS的AttributeSet){
超(背景下,ATTRS);
}
公共ExpandableHeightGridView(上下文的背景下,ATTRS的AttributeSet,诠释defStyle){
超(背景下,ATTRS,defStyle);
}
@覆盖
公共无效onMeasure(INT widthMeasureSpec,诠释heightMeasureSpec){
如果(isExpanded()){
//通过提供一个非常大的高度暗示计算整个高度。
//但不要使用最高的2位这个整数的;那些是
//保留用于MeasureSpec模式。
INT expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE的>→2,MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec,expandSpec);
ViewGroup.LayoutParams PARAMS = getLayoutParams();
params.height = getMeasuredHeight();
}
其他 {
super.onMeasure(widthMeasureSpec,heightMeasureSpec);
}
}
公共无效setExpanded(布尔扩展){
mExpanded =扩大;
}
公共布尔isExpanded(){
返回mExpanded;
}
}
我的主XML:
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
< RelativeLayout的
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:填充=@扪/ program_showview_padding
机器人:paddingTop =@扪/ program_showview_padding_top>
<的TextView
机器人:ID =@ + ID / program_category
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_toRightOf =@ ID / program_vignette
机器人:layout_alignParentRight =真/>
<的TextView
机器人:ID =@ + ID / program_sub_category
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_category
机器人:layout_toRightOf =@ ID / program_vignette
机器人:layout_alignParentRight =真/>
<的TextView
机器人:ID =@ + ID / program_duration
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_sub_category
机器人:layout_toRightOf =@ ID / program_vignette
机器人:layout_alignParentRight =真/>
< ImageView的
机器人:ID =@ + ID / program_csa
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_duration
机器人:layout_toRightOf =@ ID / program_vignette/>
<的TextView
机器人:ID =@ + ID / program_tweets_count
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_csa
机器人:layout_toRightOf =@ ID / program_vignette
机器人:layout_alignParentRight =真/>
<的TextView
机器人:ID =@ + ID / program_summary_label
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_vignette
机器人:文本=@字符串/ program_showview_summary/>
<的TextView
机器人:ID =@ + ID / program_summary
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_summary_label/>
<的TextView
机器人:ID =@ + ID / program_casting_label
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_summary
机器人:文本=FFFFFFF/>
< fr.haploid.widget.ExpandableHeightGridView
机器人:ID =@ + ID / program_casting
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / program_casting_label
机器人:为numColumns =auto_fit/>
< / RelativeLayout的>
< /滚动型>
解决方案
尝试设置你的滚动视图不成为焦点。我有同样的问题,这固定它。
yourExpandableHeightGridView.setFocusable(假);
或
机器人:可调焦=假
在XML。
On Nexus S and WildFire when displaying my ExpandableHeightGridView
, the activity
view is positioned at the bottom of the scrollview
by default.
when i launch app, ExpandableHeightGridView
with different view then main layout
automatically scroll at bottom!!!
Did any one faced the same problem?
Here is my 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;
}
}
My main 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>
解决方案
Try setting your scrollview to not be focusable. I had the same problem and this fixed it.
yourExpandableHeightGridView.setFocusable(false);
or
android:focusable="false"
in XML.
这篇关于显示位于列表的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文