У меня есть макет с множеством вложенных весов, что плохо для производительности. Как можно сделать, например, клавиатуру калькулятора без утяжелителей, но сохраняя размер кнопок, не задавая им фиксированный размер "sp" или "dp", клавиатура должна масштабироваться независимо от того, какое разрешение на экране сейчас
Я нашел решение здесь ответ CommonsWare и здесь Che Jame answer
но почему они говорят: "Используйте android: layout_weight =" 1 "на обеих кнопках" Eclipse, говоря, что я должен получить язычок весов ... Есть ли другие решения? или это невозможно в платформе android? Вот как у меня это с вложенными весами, а код ниже
Я хочу сохранить это представление, НО без вложенных весов, и кнопки должны быть того же размера, больше, чем параметр «обернуть содержимое».
Спасибо за любой совет.
<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>