我遇到了一些動態生成的按鈕問題。如果文字太多,他們會離開屏幕。你可以看到它的圖片:Android - 動態按鈕關閉屏幕
如果在按鈕上的文本是小那麼問題不出來,但如果字符數是高的,那麼按鈕上顯示出來的畫面。
按鈕的佈局如下:
<?xml version="1.0" encoding="UTF-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/newGuessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentRight="true" >
</Button>
和按鈕在表中的佈局創建:
<TableLayout android:id="@+id/buttonTableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" android:stretchColumns="0,1,2">
<TableRow android:id="@+id/tableRow0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"></TableRow>
<TableRow android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"></TableRow>
<TableRow android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"></TableRow>
重要的是要注意,這桌走了進去是很重要的線性佈局。
是否有反正我可以將按鈕的大小限制爲使用它們的屏幕大小?
你必須使用一個表嗎?怎麼樣一個gridview? – AndroidEnthusiast 2014-10-02 10:14:55
我不必使用表格。使用gridview更好嗎?它如何幫助解決這個問題? – 2014-10-02 16:45:56