0
我有一個嵌套的權重,這對於pefrormance很糟糕的佈局。 如何製作計算器鍵盤(例如沒有重量的計算器鍵盤),但是在不給予固定「sp」或「dp」大小的情況下節省按鈕大小,無論屏幕上的分辨率如何,都必須縮放鍵盤實現鍵盤佈局,沒有嵌套的重量和固定的尺寸在xml
,我發現這裏的解決方案CommonsWare answer這裏Che Jame answer
但爲什麼他們說:「使用Android:layout_weight =」鍵上的兩個」 1" Eclipse的說我必須得到權重的蘆葦... 是還有其他解決方案嗎?或者在android平臺上不可能? 這裏是我有它使用嵌套的權重,而代碼如下
我要救這個觀點,但bithout嵌套的權重和按鈕必須是相同的大小,更大然後「包裝內容」參數
感謝您的任何建議。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/cashcount_form_button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_2"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_3"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/cashcount_form_button4"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_4"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button5"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_5"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button6"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_6"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/cashcount_form_button7"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_7"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button8"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_8"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button9"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_9"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/cashcount_form_comma_button"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_comma"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_button0"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/cashcount_key_0"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
<Button
android:id="@+id/cashcount_form_delete_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableStart="@drawable/ic_action_back_sign_image_view"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>