修改样式和主题

来源:互联网 发布:python获取日期字符串 编辑:程序博客网 时间:2024/05/21 17:06
样式:首先是看到有这些组件对吧,然后呢,我们要方便修改,就在values下面style里面修改
    <TextView
       android:text="@string/hello_world"
       style="@style/jiangnanstyle"
       />
   
   <TextView
       android:text="@string/hello_world"
       style="@style/panzi"
       />
   <TextView
       android:text="@string/hello_world"
       style="@style/panzi.munai"
       />
 <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/hello_world"
       android:textSize="22sp"
       android:textColor="#ff0000"
        />
---------------------------------------------------------
style页面:
 </style>
   <stylename="jiangnanstyle">
       <itemname="android:layout_width">wrap_content</item>
       <itemname="android:layout_height">wrap_content</item>
       <itemname="android:textSize">22sp</item>
       <itemname="android:textColor">#ff0000</item>
   </style>
   <stylename="panzi"parent="jiangnanstyle">
       <itemname="android:textSize">30sp</item>
   </style>
   <stylename="panzi.munai"parent="jiangnanstyle">
       <itemname="android:textColor">#0000ff</item>
   </style>
-----------------------------------------------------------------
然后我们说说主题,主题的修改,要么用系统自带的,在清单配置文件里面处理。另外一种就是直接在style里面设置
系统自带的:
<application
       android:allowBackup="true"
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:theme="@android:style/Theme.Black">
       <activity
           android:name="com.example.styleandtheme.MainActivity"
           android:label="@string/app_name">
           <intent-filter>
               <actionandroid:name="android.intent.action.MAIN"/>

               <categoryandroid:name="android.intent.category.LAUNCHER"/>
           </intent-filter>
       </activity>
------------------------------------------------------------
style:注意,这个定义完之后,要在清单配置文件中使用
<stylename="mytheme">
       <itemname="android:background">#ff0000</item>
   </style>
在MANNIFIST中使用
android:theme="@android:style/mythmem"





0 0
原创粉丝点击