滚动在活动上的onclick监听器底部 [英] Scroll at the bottom of the activity on onclick listener
本文介绍了滚动在活动上的onclick监听器底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android应用程序,我有几个观点(按钮,EditTexts等)不可见的最初。这些都是看得见只在一个特定的按钮单击事件。我希望将滚动型移动到这些意见最终使这些都是对用户可见。
布局文件的相关部分:
<滚动型...> < RelativeLayout的机器人:ID =@ + ID / RelDevDet
机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT>
。
。
。
< ImageButton的机器人:ID =@ + ID / ibRateApp
机器人:layout_toRightOf =@ ID / tvRateApp
机器人:layout_alignTop =@ ID / tvRateApp
机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT
机器人:背景=@绘制/ arrow_up机器人:可点击=真
机器人:layout_marginRight =5DP
机器人:paddingBottom会=10dp
/>
<的RatingBar机器人:ID =@ + ID / rtApp的android:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT机器人:layout_below =@ + ID / tvRateApp
机器人:layout_marginLeft =5DP机器人:知名度=水涨船高/>
< EditText上的android:layout_width =FILL_PARENT
机器人:ID =@ + ID / etRateApp
机器人:layout_height =WRAP_CONTENT
机器人:行=3
机器人:layout_below =@ + ID / rtApp
机器人:layout_marginRight =5DP
机器人:layout_alignLeft =@ + ID / tvDevWeb
机器人:知名度=水涨船高/>
<按钮机器人:ID =@ + ID / btSubRat的android:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / etRateApp机器人:layout_margin =5DP机器人:文本=提交机器人:知名度=水涨船高/>
< / RelativeLayout的>
< /滚动型>
该按钮的onclicklistener是:
公共无效的onClick(视图v){
如果(v.getId()== R.id.ibRateApp){
Log.d(阿密特,滚动结束);
rtApp.setVisibility(View.VISIBLE);
etRateApp.setVisibility(View.VISIBLE);
//如何获得滚动视图移动到这里页的结尾?
}
}
解决方案
scroll.fullScroll(View.FOCUS_DOWN);
这固定它适合我。
In my Android app, I have a few views (Buttons, EditTexts etc.) not visible initially. These are visible only on a particular button click event. I wish to move the scrollview to the end of these views so that these are visible to the user.
The relevant portion of the layout file:
<ScrollView...>
<RelativeLayout android:id="@+id/RelDevDet"
android:layout_width="fill_parent" android:layout_height="wrap_content">
.
.
.
<ImageButton android:id="@+id/ibRateApp"
android:layout_toRightOf="@id/tvRateApp"
android:layout_alignTop="@id/tvRateApp"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/arrow_up" android:clickable="true"
android:layout_marginRight="5dp"
android:paddingBottom="10dp"
/>
<RatingBar android:id="@+id/rtApp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tvRateApp"
android:layout_marginLeft="5dp" android:visibility="gone"/>
<EditText android:layout_width="fill_parent"
android:id="@+id/etRateApp"
android:layout_height="wrap_content"
android:lines="3"
android:layout_below="@+id/rtApp"
android:layout_marginRight="5dp"
android:layout_alignLeft="@+id/tvDevWeb"
android:visibility="gone" />
<Button android:id="@+id/btSubRat" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_below="@+id/etRateApp" android:layout_margin="5dp" android:text="Submit" android:visibility="gone"/>
</RelativeLayout>
</ScrollView>
The onclicklistener for the button is:
public void onClick(View v) {
if(v.getId()== R.id.ibRateApp){
Log.d("amit","scroll end");
rtApp.setVisibility(View.VISIBLE);
etRateApp.setVisibility(View.VISIBLE);
//How to get the scrollview move to the end of the page here??
}
}
解决方案
scroll.fullScroll(View.FOCUS_DOWN);
This fixed it for me.
这篇关于滚动在活动上的onclick监听器底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文