2011-07-06 49 views

回答

26

下面是答案:)

你不需要你需要的東西的樣式文本 任何圖像,這裏是簡單和短期的方式做到這一點

button1.setText(Html.fromHtml("<b><big>" + "Title" + "</big></b>" + "<br />" + 
     "<small>" + "subtitle" + "</small>" + "<br />")); 

你做不需要更改任何佈局只需將此文本添加到您的按鈕

+0

是做了一個把戲我試試,謝謝你的回答,可以給+20如果允許:) :) – Zoombie

+0

,你受到歡迎。 。當我第一次發現這個東西的時候,我的上帝和你一樣感覺到:) – Lukap

+1

只是一個註釋:''使文本更小 –

0

可以在邏輯解決這個問題的邏輯是。

android:text="Titel \n subTitle" 

我希望這對你有幫助。

+0

Zoombie希望按鈕中的文本動態變化。所以這個解決方案是不可能的,我認爲。 – Sujit

+0

我有更新我的答案嘗試... – DynamicMind

+0

@sujit我想我應該有兩個相鄰的按鈕 – Zoombie

-1

在XML中,你可以使用相對佈局,使其他文本上按鈕的頂部。

這只是一個例子,有不累的代碼。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 


<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="25dp" 
    android:id="@+id/button" 
    android:text="Text1" /> 
<TextView 
    android:id="@+id/label" 
    android:layout_alignBottom="@id/button" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Text2"/> 
</RelativeLayout> 
相關問題