0

私の悪い英語でごめんなさい:)

最初のボタンのような他のボタンを作成する必要があります。 https://scontent-b-ams.xx.fbcdn.net/hphotos-frc1/v/577464_192010300985304_317054198_n.jpg?oh=bf0e536e576de63acf060604109797b0&oe=52777780

drawable フォルダーに shape_style.xml ファイルを作成しました

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="#33B5E5" />

    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp" />
    <corners android:radius="8dp" />
</shape>

色だけが異なる2番目のshape_style_2.xml

だから私は他のボタンのためにこれを行う必要がありますが、色だけが異なる10個のファイルを作成したくありません

私のlayout.xml

<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
        <View
            android:background="@drawable/shape_style"
            style="@style/button_home_view" />

        <TextView
            style="@style/button_home_textview"
            android:background="@drawable/shape_style_2"
            android:text="@string/button_1" />

    </FrameLayout>

この問題を解決するためのより良い方法はありますか?ありがとう

4

1 に答える 1

0

それは不可能。他のコンポーネントとは異なり、ドローアブル リソースには、他のウィジェットや色のように ID が与えられません。それらはファイル名によって、つまり R.drawable を通じて参照されます。それらは別のファイルで処理する必要があります。

より明確にするために、このドキュメントを参照してください - Drawable

于 2013-11-02T14:30:26.750 に答える