У меня есть файл макета с 16 кнопками. Щас меняю цвет, меняя все 16 кнопок. Должен быть способ лучше сделать это, поискать в гугле ничего не нашел. Я полагаю, что должен быть способ сделать amcro или что-то в этом роде, поэтому мне нужно изменить его только 1 раз.
Файл
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/butVol"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Volume"
android:textColor="#ff0000ff"
android:layout_gravity="center"
/>
<Button
android:id="@+id/butRington"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Rington"
android:textColor="#ff0000ff"
android:layout_gravity="center"
/>
android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound2"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound2"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound4"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound4"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/butSound5"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound5"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<Button
android:id="@+id/butSound6"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound6"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/butSound7"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound7"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<Button
android:id="@+id/butSound8"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound8"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound10"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound10"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/butSound11"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound11"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
<Button
android:id="@+id/butSound12"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound12"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound14"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound14"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound16"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound16"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
Android: textColor = "# ff0000ff" android: layout_marginRight = "6dp" />
<Button
android:id="@+id/butSound18"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:textSize="24px"
android:text="Sound18"
android:textColor="#ff0000ff"
android:layout_marginRight="6dp"
/>
1 ответ
Вы не должны использовать цветовой код напрямую
android:textColor="#ff0000ff"
Замените это на android:textColor="@color/xyz"
Затем определите этот цвет xyz в String.xml
В качестве альтернативы вы можете использовать тему для определения стиля или цвета. затем ваша кнопка добавляет тему
android:theme="@style/xyzStyle"
Похожие вопросы
Новые вопросы
android
Android — это мобильная операционная система Google, используемая для программирования или разработки цифровых устройств (смартфонов, планшетов, автомобилей, телевизоров, одежды, очков, IoT). Для тем, связанных с Android, используйте теги, специфичные для Android, такие как android-intent, android-activity, android-adapter и т. д. Для вопросов, отличных от разработки или программирования, но связанных с Android framework, используйте эту ссылку: https://android .stackexchange.com.