1

我在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()); 
4

2 回答 2

1
Button btn = new Button(context);
btn.setScroller(new Scroller(context)); 
btn.setVerticalScrollBarEnabled(true); 
btn.setMovementMethod(new ScrollingMovementMethod());

希望它必须有所帮助!:)

于 2012-12-26T08:36:22.077 回答
0

此属性可用于水平滚动文本:

android:scrollHorizontally
于 2012-12-26T08:33:34.037 回答