我有一个简单的笔记记录应用程序,我在滚动和操作栏时遇到问题。我希望操作栏能够在整个时间内被修复(看到),即使我向下滚动笔记或者想要复制和粘贴时也是如此。
这是我到目前为止的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/noteText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="7"
android:singleLine="false"
android:gravity="top"
android:lineSpacingExtra="7dp"
android:inputType="textMultiLine|textCapSentences|textAutoCorrect" >
<requestFocus />
</EditText>
</RelativeLayout>
这是Java代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note_editor);
Intent intent = this.getIntent();
note = new Noteitem();
note.setKey(intent.getStringExtra("key"));
note.setText(intent.getStringExtra("text"));
EditText et = (EditText) findViewById(R.id.noteText);
et.setText(note.getText());
et.setSelection(note.getText().length());
I figured out the answer.
我必须将滚动视图添加到记笔记应用程序中。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note_editor);
Intent intent = this.getIntent();
note = new Noteitem();
note.setKey(intent.getStringExtra("key"));
note.setText(intent.getStringExtra("text"));
EditText et = (EditText) findViewById(R.id.noteText);
et.setText(note.getText());
et.setSelection(note.getText().length());
ScrollView scrollable_contents = (ScrollView) findViewById(R.id.text_view);
getLayoutInflater().inflate(R.layout.activity_note_editor, scrollable_contents);
}
答案 0 :(得分:0)
听起来你需要在EditText元素中添加垂直滚动条。
添加:
android:scrollbars="vertical"
如此完整的元素将如下所示:
<EditText
android:id="@+id/noteText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="7"
android:singleLine="false"
android:gravity="top"
android:lineSpacingExtra="7dp"
android:scrollbars="vertical"
android:inputType="textMultiLine|textCapSentences|textAutoCorrect" >