Android开发中自定义string、color、style、drawable,title,布局页面(include)的资源使用方法.txt

**重点内容**
1、自定义string资源

   <string name="word_jishibu">记事簿</string>
    <string name="word_accountlist">我的账单</string>
    <string name="word_myaccount">我的账户</string>
Java代码中的引用
title_tv.setText(getResources().getString(R.string.word_accountlist));

2、自定义color资源:

  <color name="ssjGrey">#595959</color>
    <color name="ssjBule">#269ce2</color>
    <color name="ssjXiaHuaxian">#639fd3</color>

  Java中的引用:

  ColorBlue= ContextCompat.getColor(this,R.color.ssjBule);        ColorGrey=ContextCompat.getColor(this,R.color.ssjGrey);


3、自定义布局在xml中引用:
 <include layout="@layout/title_layout"></include>

4、自定义drawable作为按钮背景(绘图)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:color="#019342"
        android:width="2dp"></stroke>
    <corners android:radius="5dp"></corners>
    <padding android:top="8dp"></padding>
    <padding android:bottom="8dp"></padding>
    <padding android:left="8dp"></padding>
    <padding android:right="8dp"></padding>
</shape>

在xml布局文件中使用;
 android:background="@drawable/bottom_login"
5.自定义title的引用

 <LinearLayout
        android:id="@+id/ll_wx"
        style="@style/tab_style">
6、自定义style

 <style name="tab_style">
        <item name="android:gravity">center</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_weight">1</item>
    </style>

引用:

<LinearLayout
       style="@style/tab_style">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值