Note that there are some explanatory texts on larger screens.

plurals
  1. PORotated editText not showing correctly
    text
    copied!<p>I wrote the code for rotating text using <code>SurfaceView</code>, which is ok. Now I want to edit the text in the <code>SurfaceView</code> which I did earlier. An <code>editText</code> will appear and editing is ok, but when I rotate the text the <code>textView</code> doesn't rotate along with the text. </p> <p>Code I use for adding and rotating the <code>editText</code> is as follows:</p> <pre><code>if(editText!= null) relativeLayout.removeView(editText); else { editText = new EditText(MainActivity.this); editText.setText(rectF.getText()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) rectF.getBounds().width(), (int) rectF.getBounds().height()); params.leftMargin = (int) rectF.getBounds().left; params.topMargin = (int) rectF.getBounds().top; editText.setLayoutParams(params); Animation an = new RotateAnimation(0,rectF.getAngle()); an.setDuration(0); an.setRepeatCount(0); an.setZAdjustment(Animation.ZORDER_TOP); an.setFillAfter(true); editText.setAnimation(an); relativeLayout.addView(editText); editText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService (Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); editText.setOnKeyListener( new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: saveEditText(); return true; } return true; } private void saveEditText() { txt2.setText(editText.getText().toString()); InputMethodManager imm = (InputMethodManager) getSystemService( INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); relativeLayout.removeView(editText); } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload