我在 android 中动态声明了一个按钮,其宽度和高度为 wrap_content。 我希望文本可以在按钮内滚动,而不是向下调整以增加按钮的高度。任何人都可以帮助解决这个问题。
提前致谢,
代码示例:
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
110,LinearLayout.LayoutParams.WRAP_CONTENT);
Button newButton = new Button(ctx);
newButton.setLayoutParams(params);
newButton.setText("some nameeeeeeeeeeeee");
newButton.setScroller(new Scroller(getActivity()));
newButton.setVerticalScrollBarEnabled(true);
newButton.setMovementMethod(new ScrollingMovementMethod());
最佳答案
Button btn = new Button(context);
btn.setScroller(new Scroller(context));
btn.setVerticalScrollBarEnabled(true);
btn.setMovementMethod(new ScrollingMovementMethod());
希望对您有所帮助! :)
关于android - 如何在android中使文本在按钮内滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14037926/