カテゴリー:
アプリ ソースコード
閲覧数:462 配信日:2013-07-27 07:46
2種類
1.XMLファイルにより設定
2.Javaファイルにより設定
1.XMLファイルにより設定
1-1.★★.xmlに直書
1-2.colors.xmlで指定
1-1.★★.xmlに直書
android:textColor
▼/res/layout/item.xml
「android:background」とは異なり、LinearLayoutタブに直接記述できない
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
複数箇所記述した場合、後から色変更するのは大変
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/item_text1"
android:textColor="#ffff00"
android:gravity="center"
android:padding="8.5dip"
/>
<!--上の直線-->
<LinearLayout
android:id="@+id/Linear01"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
</LinearLayout>
<!-- ここまで上の直線 -->
<!--項目-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="12dip"
>
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text2"
android:textColor="#ffff00"
/>
1-2.colors.xmlで指定
▼/res/layout/item.xml
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text2"
android:textColor="@color/yellow"
/>
<EditText
android:id="@+id/item_edit1"
android:layout_width="200px"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/item_button1"
android:layout_width="80px"
android:layout_height="wrap_content"
android:background ="@android:drawable/ic_menu_search"
android:layout_marginLeft="20.0px"
/>
</LinearLayout>
<!--項目終わり-->
<!--内訳-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="12dip"
>
<TextView
android:layout_width="120px"
android:layout_height="wrap_content"
android:text="@string/item_text3"
android:textColor="@color/yellow"
/>
▼/res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="yellow">#FFFF00</color>
</resources>