我想在编辑文本中ScrollText,也显示滚动条在角落。我用鼠标滚动文本
questionEntry.setScroller(new Scroller(myContext));
questionEntry.setMaxLines(1);
questionEntry.setVerticalScrollBarEnabled(true);
questionEntry.setMovementMethod(new ScrollingMovementMethod()); 可以滚动文本,但看不到ScrollBar。如何才能使其可见?
发布于 2011-07-02 18:22:03
这可能会对你有帮助。
<EditText android:id="@+id/edt_task_disc" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="top"
android:background="@drawable/text_aerea"
android:hint="Task Discription"
android:textSize="15sp" android:paddingLeft="5dp"
android:maxHeight="35dp"
android:scrollbars="vertical"
/>请将android:scrollbars="vertical"添加到编辑文本的xml代码中,它将正常工作。
发布于 2013-05-24 19:31:26
仅
示例
在Java文件中
EditText dwEdit = (EditText) findViewById(R.id.DwEdit);
dwEdit.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
if (view.getId() ==R.id.DwEdit) {
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction()&MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
});在您的
文件中...
<EditText
android:id="@+id/DwEdit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="9"
android:ems="10"
android:gravity="top"
android:imeOptions="flagNoExtractUi"
android:minLines="10"
android:scrollHorizontally="false"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:overScrollMode="always"
android:inputType="textCapSentences">
</EditText>发布于 2019-04-28 13:30:24
我也查过了,但我觉得
android:scrollbars="vertical"这是最好的方法,也可以通过定义multiline来实现
android:inputType="textMultiLine"或者,您也可以通过以下方式解决此问题
edittext.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
return false;
}
});https://stackoverflow.com/questions/6555986
复制相似问题