2013-04-21 53 views
0

我正在設計一個計算器應用程序,我需要一些「少」重要的按鈕來縮小。我有一個LinearLayout,我已經將按鈕的高度設置爲16dp。我也將字體設置爲10sp,但如果我不包含wrap_content,文本將不顯示。如何在android上使用小按鈕並仍然顯示文本?

我也讀過關於填充可能是一個問題,我已經確保它等於零。

無論如何有一個小按鈕,仍然顯示文本嗎?

按鈕的代碼:

   <Button 
        android:id="@+id/SIN" 
        android:layout_width="fill_parent" 
        android:layout_height="16dp" 
        android:layout_marginBottom="@dimen/button_marg" 
        android:layout_marginLeft="@dimen/button_marg" 
        android:layout_marginRight="@dimen/button_marg" 
        android:layout_marginTop="@dimen/button_marg" 
        android:background="@drawable/keypad1" 
        android:minHeight="12dp" 
        android:minWidth="0dp" 
        android:onClick="onClick" 
        android:text="sin" 
        android:textSize="@dimen/spec_button_text_size" /> 

回答

1

使用android:padding="0dp"如果沒有neccessary不使用保證金

+0

謝謝!解決了問題!我已經在背景文件「keypad1」中設置了所有方向的填充0,但這並沒有幫助。 – Euklides 2013-04-21 18:22:12

+0

有一個默認的填充..這需要在按鈕內的空間..這就是爲什麼我改變爲0dp ..很高興知道你的問題解決了:) – stinepike 2013-04-21 18:23:25

0

減少文字大小和layout_width和layout_height,包裝內容應該工作了。你可以使用layout_weight attibute按鈕。假設你有5個按鈕,如果你沒有爲它們指定layout_weight,Android會自動將LinearLayout分成5個部分,其中每個按鈕都可以同樣適用,但是你可以自己指定這個屬性來使按鈕變小,就像你在4個按鈕上給出0.1最後一個按鈕爲0.6。

P.S.通常總數應該等於1,但是如果您想要更改它,也可以在名爲layout_weightSum =「」的LinearLayout屬性中指定它。「」

相關問題