【发布时间】:2019-02-15 20:12:14
【问题描述】:
我在滚动视图中有一堆文本视图和编辑文本表单,并且在这个线性布局中有一个垂直的文本视图在同一个滚动视图内的表单下方有一个线性布局。当用户按下“添加更多信息”时,最初线性布局的可见性消失了,它就在这个线性布局的上方,按钮然后布局可见性是可见的。这按预期工作正常,但我想要的是当线性布局变得可见时,滚动视图应该向下滚动,以便用户可以看到扩展数据。我尝试了所有但没有什么可以帮助我。 请帮我解决这个问题。下面是 ShowHideLayout 方法。 需要帮助
fun showHideLayout() {
if (linearLayoutAddMoreInfoExpand.visibility == GONE) {
linearLayoutAddMoreInfoExpand.visibility = VISIBLE
mTextViewAddMoreInfo.setText("Close Add More Info")
scrollView.post(Runnable {
scrollView.fullScroll(ScrollView.FOCUS_DOWN)
//scrollView.scrollTo(0,scrollView.bottom)
})
// scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
scrollView.scrollTo(0,scrollView.bottom)
//scrollView.smoothScrollBy(R.id.linearLayoutAddMoreInfoExpand,R.id.scrollBottom)
} else if (linearLayoutAddMoreInfoExpand.visibility== VISIBLE) {
linearLayoutAddMoreInfoExpand.visibility = GONE
mTextViewAddMoreInfo.setText("+ Add More Info")
}
}
【问题讨论】:
标签: java android kotlin scrollview android-linearlayout