Android入门--style.xml设置和应用

来源:互联网 发布:linux 重启jenkins 编辑:程序博客网 时间:2024/06/06 02:49

在res/values中添加style.xml文件,如下:

<resources>        <style name="myStyle_Text1"><item name="android:textSize">25sp</item><item name="android:textColor">#80FF00</item></style><style name="myStyle_Text2"><item name="android:textSize">18sp</item><item name="android:textColor">#0C688E</item><item name="android:fromAlpha">0.0</item><item name="android:toAlpha" >0.0</item></style></resources>
activity_forwarding.xml文件代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.example.forwarding.Forwarding" >    <Button        android:id="@+id/button1"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="20dp"        android:text="@string/Btn01" />    <TextView        android:id="@+id/textView1"        style="@style/myStyle_Text1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/button1"        android:layout_marginTop="20dp"        android:text="@string/Texts"        android:textAppearance="?android:attr/textAppearanceLarge" />        <TextView        android:id="@+id/textView2"        style="@style/myStyle_Text2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/textView1"        android:layout_marginTop="20dp"        android:text="@string/Texts"        android:textAppearance="?android:attr/textAppearanceLarge" />    </RelativeLayout>





0 0
原创粉丝点击