[英]How do I make the action bar fixed? UPDATED
I have a simple note taking app and I'm having trouble with scrolling and the action bar. 我有一个简单的笔记应用程序,但在滚动和操作栏上遇到了麻烦。 I would like for the action bar to be fixed (seen) the entire time even as I scroll down my notes or when I want to copy and paste.
我希望动作栏在整个时间内都固定(可见),即使我向下滚动笔记或要复制和粘贴时也是如此。
Here is the code that I have so far: 这是我到目前为止的代码:
<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>
Here is the Java Code: 这是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.
I had to add the scroll view to the note taking app. 我必须将滚动视图添加到笔记应用程序中。
@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);
}
Sounds like you need to add vertical scroll bars to your EditText element. 听起来您需要向EditText元素添加垂直滚动条。
Add this: 添加:
android:scrollbars="vertical"
So complete element will look like: 因此,完整的元素将如下所示:
<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" >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.