我该如何改变按钮中文本的方向,以便它们垂直写入而不是水平写入?更改按钮上文本的方向
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.10"
android:text="Previous" />
这可能吗?
我该如何改变按钮中文本的方向,以便它们垂直写入而不是水平写入?更改按钮上文本的方向
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.10"
android:text="Previous" />
这可能吗?
我固定它自己。我制作了一个名为layout-land的独立文件夹,并在其中放置了一个单独的XML文件来处理这个问题。现在布局看起来都很好,我可以使用硬编码权重来表示属性。
试过并测试过这个,它的工作非常好。
public class buttonCustom extends Button{
String s="";
public buttonCustom(Context context) {
super(context);
}
public buttonCustom(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public buttonCustom(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public void setText(CharSequence text, BufferType type) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
for(int i=0;i<text.length();i++)
{
if(s==null)
s="";
s= s+String.valueOf(text.charAt(i))+ "\n";
}
super.setText(s, type);
}
}
改写按钮类和重写的setText功能
我认为如果你设置的按钮是垂直的(形状因子),文本应该如下。另一件事是如果你想要文本垂直显示,从下到上。 – g00dy 2013-03-06 11:44:31
看看这个问题.... http://stackoverflow.com/questions/8604932/android-text-view-text-in-vertical-direction – 2013-03-06 11:46:34
或者你可以用喜欢使用Html.fromHtml()打破例如小号
一个
,不是高贵的解决方案,但将努力 – Waqas 2013-03-06 11:47:03