下面列出了怎么用android.text.method.ScrollingMovementMethod的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar()
.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.actionBar));
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mPreviousStateView = (TextView) findViewById(R.id.previous_state);
mCurrentStateView = (TextView) findViewById(R.id.current_state);
mDebugLogView = (TextView) findViewById(R.id.debug_log);
mDebugLogView.setVisibility(DEBUG ? View.VISIBLE : View.GONE);
mDebugLogView.setMovementMethod(new ScrollingMovementMethod());
mName = generateRandomName();
((TextView) findViewById(R.id.name)).setText(mName);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar()
.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.actionBar));
mPreviousStateView = (TextView) findViewById(R.id.previous_state);
mCurrentStateView = (TextView) findViewById(R.id.current_state);
mDebugLogView = (TextView) findViewById(R.id.debug_log);
mDebugLogView.setVisibility(DEBUG ? View.VISIBLE : View.GONE);
mDebugLogView.setMovementMethod(new ScrollingMovementMethod());
mName = generateRandomName();
((TextView) findViewById(R.id.name)).setText(mName);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_routeguide);
hostEdit = (EditText) findViewById(R.id.host_edit_text);
portEdit = (EditText) findViewById(R.id.port_edit_text);
startRouteGuideButton = (Button) findViewById(R.id.start_route_guide_button);
exitRouteGuideButton = (Button) findViewById(R.id.exit_route_guide_button);
getFeatureButton = (Button) findViewById(R.id.get_feature_button);
listFeaturesButton = (Button) findViewById(R.id.list_features_button);
recordRouteButton = (Button) findViewById(R.id.record_route_button);
routeChatButton = (Button) findViewById(R.id.route_chat_button);
resultText = (TextView) findViewById(R.id.result_text);
resultText.setMovementMethod(new ScrollingMovementMethod());
disableButtons();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewResult = findViewById(R.id.textViewResult);
textViewResult.setMovementMethod(new ScrollingMovementMethod());
btnDetectObject = findViewById(R.id.btnDetectObject);
btnDetectObject.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("image/*");
startActivityForResult(intent,CHOOSE_PHOTO);//打开相册
}
});
mContentView = (ImageView) findViewById(R.id.content);
initTensorFlowAndLoadModel();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
logger = SimpleLogger.getInstance(getContext());
waltDevice = WaltDevice.getInstance(getContext());
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_accelerometer, container, false);
logTextView = (TextView) view.findViewById(R.id.txt_log);
startButton = view.findViewById(R.id.button_start);
latencyChart = (ScatterChart) view.findViewById(R.id.latency_chart);
latencyChartLayout = view.findViewById(R.id.latency_chart_layout);
logTextView.setMovementMethod(new ScrollingMovementMethod());
view.findViewById(R.id.button_close_chart).setOnClickListener(this);
sensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (accelerometer == null) {
logger.log("ERROR! Accelerometer sensor not found");
}
return view;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_tap_histogram, true);
if (getBooleanPreference(getContext(), R.string.preference_systrace, true)) {
traceLogger = TraceLogger.getInstance();
}
waltDevice = WaltDevice.getInstance(getContext());
logger = SimpleLogger.getInstance(getContext());
// Inflate the layout for this fragment
final View view = inflater.inflate(R.layout.fragment_tap_latency, container, false);
restartButton = (ImageButton) view.findViewById(R.id.button_restart_tap);
finishButton = (ImageButton) view.findViewById(R.id.button_finish_tap);
tapCatcherView = (TextView) view.findViewById(R.id.tap_catcher);
logTextView = (TextView) view.findViewById(R.id.txt_log_tap_latency);
tapCountsView = (TextView) view.findViewById(R.id.txt_tap_counts);
moveCountsView = (TextView) view.findViewById(R.id.txt_move_count);
latencyChart = (HistogramChart) view.findViewById(R.id.latency_chart);
logTextView.setMovementMethod(new ScrollingMovementMethod());
finishButton.setEnabled(false);
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_any_path);
setTitle("Get Path..");
pathText = (EditText) findViewById(R.id.path_edittext);
fieldsText = (EditText) findViewById(R.id.fields_edittext);
responseView = (TextView) findViewById(R.id.path_response_view);
responseView.setMovementMethod(new ScrollingMovementMethod());
getButton = (Button) findViewById(R.id.get_button);
getButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onGet();
}
});
spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.paths_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_message_me, container, false);
mSendSingleConversation = (Button) rootView.findViewById(R.id.send_1_conversation);
mSendSingleConversation.setOnClickListener(this);
mSendTwoConversations = (Button) rootView.findViewById(R.id.send_2_conversations);
mSendTwoConversations.setOnClickListener(this);
mSendConversationWithThreeMessages =
(Button) rootView.findViewById(R.id.send_1_conversation_3_messages);
mSendConversationWithThreeMessages.setOnClickListener(this);
mDataPortView = (TextView) rootView.findViewById(R.id.data_port);
mDataPortView.setMovementMethod(new ScrollingMovementMethod());
mClearLogButton = (Button) rootView.findViewById(R.id.clear);
mClearLogButton.setOnClickListener(this);
setButtonsState(false);
return rootView;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.social_media_content);
socialMediaLoginButton = findViewById(R.id.social_media_content_log_in_btn);
socialMediaLogoutButton = findViewById(R.id.social_media_content_log_out_btn);
socialMediaContentTextView = findViewById(R.id.social_media_content_tv);
socialMedialContentImageView = findViewById(R.id.social_media_content_iv);
socialMediaContentTextView.setMovementMethod(new ScrollingMovementMethod());
if (getIntent().getExtras() != null) {
String socialMediaType = getIntent().getExtras().getString(SOCIAL_MEDIA_TYPE);
updateSocialMediaState(socialMediaType);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(socialMediaType);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_service, container, false);
mETLog = (TextView) view.findViewById(R.id.tv_log);
mETLog.setMovementMethod(ScrollingMovementMethod.getInstance());
view.findViewById(R.id.btn_start_plugin_intent_service).setOnClickListener(this);
view.findViewById(R.id.btn_start_plugin_service).setOnClickListener(this);
view.findViewById(R.id.btn_stop_plugin_service).setOnClickListener(this);
view.findViewById(R.id.btn_bind_plugin_service).setOnClickListener(this);
view.findViewById(R.id.btn_unbind_plugin_service).setOnClickListener(this);
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_routeguide);
hostEdit = (EditText) findViewById(R.id.host_edit_text);
portEdit = (EditText) findViewById(R.id.port_edit_text);
startRouteGuideButton = (Button) findViewById(R.id.start_route_guide_button);
exitRouteGuideButton = (Button) findViewById(R.id.exit_route_guide_button);
getFeatureButton = (Button) findViewById(R.id.get_feature_button);
listFeaturesButton = (Button) findViewById(R.id.list_features_button);
recordRouteButton = (Button) findViewById(R.id.record_route_button);
routeChatButton = (Button) findViewById(R.id.route_chat_button);
resultText = (TextView) findViewById(R.id.result_text);
resultText.setMovementMethod(new ScrollingMovementMethod());
disableButtons();
}
private void initView() {
this.m3thLogo = (ImageView) this.mRootView.findViewWithTag("umgr_oauth2_3th_logo");
this.mCoolCloudLogo = (ImageView) this.mRootView.findViewWithTag("umgr_oauth2_coolcloud_logo");
this.m3thName = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_3th_name");
this.mRelation = (ImageView) this.mRootView.findViewWithTag("umgr_oauth2_relation");
this.mAccountLogo = (ImageView) this.mRootView.findViewWithTag("umgr_oauth2_coolcloud_logo");
this.mAccountTv = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_coolcloud_name");
this.mUserLogo = (ImageView) this.mRootView.findViewWithTag("umgr_oauth2_user_logo");
this.mUserAccount = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_user_account");
this.mSwitchAccount = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_switch_account");
this.mOAuth2 = (Button) this.mRootView.findViewWithTag("umgr_oauth2_submit");
this.mOAuth2Scope = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_scope");
this.mErrorPrompt = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_error_prompt");
this.mOAuth2Prompt = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_prompt");
this.mCoolCloudName = (TextView) this.mRootView.findViewWithTag("umgr_oauth2_coolcloud_name");
this.mOAuth2Scope.setMovementMethod(ScrollingMovementMethod.getInstance());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewLog = (TextView) findViewById(R.id.textViewLog);
wifiScannerIntent = new Intent(this, WifiScannerService.class);
textViewLog.setMovementMethod(new ScrollingMovementMethod());
sharedPreferences = getSharedPreferences("karmaDetectorPrefs", Context.MODE_PRIVATE);
scanFrequencyText = (EditText) findViewById(R.id.scanFrequency);
scanFrequencyText.addTextChangedListener(frequencyScanTextWatcher);
autoStartSwitch = (Switch) findViewById(R.id.switchAutoStart);
autoStartSwitch.setOnCheckedChangeListener(autoStartSwitchWatcher);
loadPrefs();
addToLog("App started.");
}
@Override
public void run() {
waltDevice.stopListener();
waltDevice.clearTriggerHandler();
// TODO: Add option to save this data into a separate file rather than the main log.
logger.log(brightnessCurveData.toString());
logger.log("=== End of screen brightness data ===");
blackBox.setText(logger.getLogText());
blackBox.setMovementMethod(new ScrollingMovementMethod());
blackBox.setBackgroundColor(color_gray);
isTestRunning = false;
startButton.setEnabled(true);
setFullScreen(false);
drawBrightnessChart();
LogUploader.uploadIfAutoEnabled(getContext());
}
/**
* 设置值
*/
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
// viewHolder.mImg.setImageResource(mDatas.get(i).pic);
// Glide.with(getContext()).load(mDatas.get(i).pic).into(viewHolder.mImg);
viewHolder.mImg.setImageResource(mDatas.get(i));
viewHolder.mTxt.setText("艾弗森");
viewHolder.mTxt.setMovementMethod(ScrollingMovementMethod.getInstance());
// viewHolder.itemView.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View view) {
// int position = viewHolder.getPosition();
// onItemClickListener.OnItemClick(view, position);
// }
// });
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vFloat = new FloatView(this);
vResult = (TextView) findViewById(R.id.result);
findViewById(R.id.result).setOnClickListener(this);
findViewById(R.id.check).setOnClickListener(this);
findViewById(R.id.manage).setOnClickListener(this);
findViewById(R.id.toggle).setOnClickListener(this);
findViewById(R.id.detail).setOnClickListener(this);
TextView tv = (TextView) findViewById(R.id.info);
tv.setMovementMethod(ScrollingMovementMethod.getInstance());
tv.setText(readString("/system/build.prop"));
if (SettingsCompat.canDrawOverlays(this)) {
vFloat.attach();
} else {
vFloat.detach();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bidi_info);
Intent intent = getIntent();
mBidiText = String.valueOf(intent.getCharSequenceExtra(BIDI_TEXT));
mDensity = getResources().getDisplayMetrics().scaledDensity;
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
SpannableStringBuilder builder = new SpannableStringBuilder();
writeBidiText(builder);
TextView bidiTextView = findViewById(R.id.text_view_bidi);
bidiTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
bidiTextView.setText(builder);
}
private void loadViews() {
mVideoView = (VideoView) findViewById(R.id.videoView1);
mTitleView = (TextView) findViewById(R.id.textView1);
mDescriptionView = (TextView) findViewById(R.id.textView2);
mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
mAuthorView = (TextView) findViewById(R.id.textView3);
mStartText = (TextView) findViewById(R.id.startText);
mStartText.setText(Utils.formatMillis(0));
mEndText = (TextView) findViewById(R.id.endText);
mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
mPlayPause = (ImageView) findViewById(R.id.imageView2);
mLoading = (ProgressBar) findViewById(R.id.progressBar1);
mControllers = findViewById(R.id.controllers);
mContainer = findViewById(R.id.container);
mCoverArt = (ImageView) findViewById(R.id.coverArtView);
ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
mPlayCircle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
togglePlayback();
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_helloworld);
sendButton = (Button) findViewById(R.id.send_button);
hostEdit = (EditText) findViewById(R.id.host_edit_text);
portEdit = (EditText) findViewById(R.id.port_edit_text);
messageEdit = (EditText) findViewById(R.id.message_edit_text);
resultText = (TextView) findViewById(R.id.grpc_response_text);
resultText.setMovementMethod(new ScrollingMovementMethod());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clientcacheexample);
sendButton = (Button) findViewById(R.id.send_button);
hostEdit = (EditText) findViewById(R.id.host_edit_text);
portEdit = (EditText) findViewById(R.id.port_edit_text);
messageEdit = (EditText) findViewById(R.id.message_edit_text);
getCheckBox = (CheckBox) findViewById(R.id.get_checkbox);
noCacheCheckBox = (CheckBox) findViewById(R.id.no_cache_checkbox);
onlyIfCachedCheckBox = (CheckBox) findViewById(R.id.only_if_cached_checkbox);
resultText = (TextView) findViewById(R.id.grpc_response_text);
resultText.setMovementMethod(new ScrollingMovementMethod());
cache = SafeMethodCachingInterceptor.newLruCache(CACHE_SIZE_IN_BYTES);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_terminal, container, false);
receiveText = view.findViewById(R.id.receive_text); // TextView performance decreases with number of spans
receiveText.setTextColor(getResources().getColor(R.color.colorRecieveText)); // set as default color to reduce number of spans
receiveText.setMovementMethod(ScrollingMovementMethod.getInstance());
TextView sendText = view.findViewById(R.id.send_text);
View sendBtn = view.findViewById(R.id.send_btn);
sendBtn.setOnClickListener(v -> send(sendText.getText().toString()));
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_info_rec);
// Show the Up button in the action bar.
setupActionBar();
analyzerUtil = new AnalyzerUtil(this);
testResultSt = null;
final TextView tv = (TextView) findViewById(R.id.info_rec_tv);
tv.setMovementMethod(new ScrollingMovementMethod());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etHost = findViewById(R.id.etHost);
etPort = findViewById(R.id.etPort);
etContent = findViewById(R.id.etContent);
tvContent = findViewById(R.id.tvContent);
tvContent.setMovementMethod(ScrollingMovementMethod.getInstance());
etHost.setText(mHost);
etPort.setText(String.valueOf(mPort));
initNetty();
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_terminal, container, false);
receiveText = view.findViewById(R.id.receive_text); // TextView performance decreases with number of spans
receiveText.setTextColor(getResources().getColor(R.color.colorRecieveText)); // set as default color to reduce number of spans
receiveText.setMovementMethod(ScrollingMovementMethod.getInstance());
TextView sendText = view.findViewById(R.id.send_text);
View sendBtn = view.findViewById(R.id.send_btn);
sendBtn.setOnClickListener(v -> send(sendText.getText().toString()));
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.text_view);
textView.setMovementMethod(new ScrollingMovementMethod());
}
void showPermissionExplanation(int resId) {
TextView tv = new TextView(activity);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setText(fromHtml(activity.getString(resId)));
new AlertDialog.Builder(activity)
.setTitle(R.string.permission_explanation_title)
.setView(tv)
.setNegativeButton(R.string.dismiss, null)
.create().show();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detection_test);
progress = (TextView) findViewById(R.id.progressText);
progress.setMovementMethod(new ScrollingMovementMethod());
}
protected void initialize(Context aContext) {
inflate(aContext, R.layout.prompt_text, this);
mAudio = AudioEngine.fromContext(aContext);
mLayout = findViewById(R.id.layout);
mTitle = findViewById(R.id.textTitle);
mMessage = findViewById(R.id.textMessage);
mMessage.setMovementMethod(new ScrollingMovementMethod());
mPromptText = findViewById(R.id.promptText);
mOkButton = findViewById(R.id.positiveButton);
mOkButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}
if (mPromptDelegate != null && mPromptDelegate instanceof TextPromptDelegate) {
((TextPromptDelegate)mPromptDelegate).confirm(mPromptText.getText().toString());
}
hide(REMOVE_WIDGET);
});
mCancelButton = findViewById(R.id.negativeButton);
mCancelButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}
onDismiss();
});
}
@Override
public void onResume() {
super.onResume();
textView = (TextView) activity.findViewById(R.id.txt_log);
textView.setMovementMethod(new ScrollingMovementMethod());
textView.setText(logger.getLogText());
logger.registerReceiver(logReceiver);
}
public LyricView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setFocusable(true);
int backgroundColor = Color.BLACK;
int highlightColor = Color.RED;
int normalColor = Color.WHITE;
setBackgroundColor(backgroundColor);
// Non-highlight part
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextSize(36);
mPaint.setColor(normalColor);
mPaint.setTypeface(Typeface.SERIF);
// highlight part, current lyric
mCurrentPaint = new Paint();
mCurrentPaint.setAntiAlias(true);
mCurrentPaint.setColor(highlightColor);
mCurrentPaint.setTextSize(36);
mCurrentPaint.setTypeface(Typeface.SANS_SERIF);
mPaint.setTextAlign(Paint.Align.CENTER);
mCurrentPaint.setTextAlign(Paint.Align.CENTER);
setHorizontallyScrolling(true);
setMovementMethod(new ScrollingMovementMethod());
}