滚动视图的平滑滚动
问题描述:
我正在使用ScrollView查看文件。问题是,当我滚动时,它很粘,不太光滑。我找到了一个非常流畅的警告对话框代码。有什么办法让ScrollView上的滚动像alert对话框一样吗?怎么样?滚动视图的平滑滚动
下面是滚动型实现的例子:
公共无效buttonLoad(查看视图){
File file = new File(path + "/savedFile.txt");
String [] loadText = Load(file);
String finalString = "";
for(int i = 0; i<loadText.length; i++)
{
finalString += loadText[i] + System.getProperty("line.separator");
}
//textView.setText(finalString);
//textView.setMovementMethod(new ScrollingMovementMethod());
textView.setMovementMethod(new ScrollingMovementMethod());
textView.setText(finalString);
/*String title = "title";
String Message = finalString;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(Message);
builder.show();*/
}
答
使用RecyclerView。这个滚动视图比平常快。
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerSelectGame"
>
</android.support.v7.widget.RecyclerView>
+0
https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html –
什么对话框?你的榜样在哪里? –
@ cricket_007这是我的第一个查询。我试图发布一些代码,但似乎太长。你能帮我吗? –
试着创建你的代码的[mcve],并且你可以链接到示例对话框。 [编辑]相应 –