zoukankan      html  css  js  c++  java
  • 基本控件设置边角图片 drawableleft

    btn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_galley_comment, 0, 0,0);

    四个参数分别是左上右下四个方向的图片全设为0则为不设图片

    设置布局文件  点击图片选择器

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/tab4_down" android:state_checked="true"></item>
    <item android:drawable="@mipmap/tab4"></item>
    </selector>

    文字颜色选择器
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#ffff8761" android:state_checked="true"> </item>

    <item android:color="#000"> </item>
    </selector>

    风格设定
     1 <resources>
     2 
     3     <!-- Base application theme. -->
     4     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
     5         <!-- Customize your theme here. -->
     6     </style>
     7   <!-- 主页面RadioButton做Tab-->
     8     <!-- 使用Parent.Child形式定义属性名称-->
     9     <style name="AppTheme.MainTabItem">
    10         <item name="android:layout_width">0dp</item>
    11         <item name="android:layout_weight">1</item>
    12         <item name="android:layout_height">wrap_content</item>
    13         <item name="android:gravity">center</item>
    14         <item name="android:button">@null</item>
    15         <item name="android:textColor">@color/main_tab_item_text_color</item>
    16     </style>
    17 </resources>
    style.xml

    具体使用

    <RadioButton
    android:checked="true"
    android:id="@+id/main_tab_item_discover"
    android:text="发现"
    android:drawableTop="@drawable/tab_discover"
    style="@style/AppTheme.MainTabItem"
    />
  • 相关阅读:
    div 水平居中 内容居左
    net core 踩坑记录
    正向代理和反向代理
    NOIP2013 | 货车运输
    【转载】字符串Hash & 【题解】好文章
    cqyz oj | 帮助Jimmy | DAG图
    cqyz oj | 猜序列
    转载 | 原码, 反码, 补码 详解
    cqyz oj | 有线电视网
    cqyz oj | 罕见的秩序 | 拓扑排序
  • 原文地址:https://www.cnblogs.com/bimingcong/p/4849139.html
Copyright © 2011-2022 走看看