我已经有了滚动滚动视图的代码一直向下onCreate。但我的问题是我用来实现这一目的的代码使自动滚动变得更快。我需要慢慢滚动滚动视图。我需要这样做,因为我有一个正在阅读我工作内容的narator。因此我想在Narator阅读时自动向下滚动内容。为此,我使用以下代码:
final ScrollView sv = (ScrollView) findViewById(R.id.sv);
sv.fullScroll(sv.FOCUS_DOWN);
sv.postDelayed(new Runnable() {
@Override
public void run() {
sv.fullScroll(sv.FOCUS_DOWN);
}
},100L);
这里也是我的所有代码
package org.intercode.lifeatceu;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
public class pm extends AppCompatActivity {
LinearLayout ll;
MediaPlayer mpPM;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pm);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ll = (LinearLayout) findViewById(R.id.ll);
mpPM = MediaPlayer.create(this,R.raw.pm);
mpPM.start();
final ScrollView sv = (ScrollView) findViewById(R.id.sv);
sv.fullScroll(sv.FOCUS_DOWN);
sv.postDelayed(new Runnable() {
@Override
public void run() {
sv.fullScroll(sv.FOCUS_DOWN);
}
},100L);
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu_mainmenu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
int id = item.getItemId();
switch(id){
case R.id.menu_home:
startActivity(new Intent(this, mainmenu.class));
mpPM.stop();
break;
case R.id.menu_browse:
startActivity(new Intent(this, browse.class));
mpPM.stop();
break;
case R.id.menu_quiz:
startActivity(new Intent(this, Chooselevel.class));
mpPM.stop();
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{
mpPM.stop();
startActivity(new Intent(getApplicationContext(), browse.class));
}
@Override
protected void onStop()
{
super.onStop();
mpPM.stop();
}
}
我的问题是,如何更改滚动的速度?