android-R.color

R.color

public static final class R.color 
extends Object 

java.lang.Object
   ↳ android.R.color


Summary



Constants

int background_dark

int background_light

int black

int darker_gray

int holo_blue_bright

A really bright Holo shade of blue

int holo_blue_dark

A dark Holo shade of blue

int holo_blue_light

A light Holo shade of blue

int holo_green_dark

A dark Holo shade of green

int holo_green_light

A light Holo shade of green

int holo_orange_dark

A dark Holo shade of orange

int holo_orange_light

A light Holo shade of orange

int holo_purple

A Holo shade of purple

int holo_red_dark

A dark Holo shade of red

int holo_red_light

A light Holo shade of red

int primary_text_dark

int primary_text_dark_nodisable

int primary_text_light

int primary_text_light_nodisable

int secondary_text_dark

int secondary_text_dark_nodisable

int secondary_text_light

int secondary_text_light_nodisable

int tab_indicator_text

int tertiary_text_dark

int tertiary_text_light

int transparent

int white

int widget_edittext_dark



Color

XML格式定义的颜色值。用RGB值和alpha通道指定颜色值。可以在任何接受十六进制颜色值的地方使用color资源。还能在XML里用到drawable资源时使用color 资源(比如:android:drawable="@color/green")。

颜色值总是以(#)字符开头,后面跟着Alpha--绿-蓝信息,格式如下之一:

·       #RGB

·       #ARGB

·       #RRGGBB

·       #AARRGGBB

注意:color是简单类型资源,是用名称(name)属性(而非XML文件名)来直接引用的。因此,在一个XML文件里,可以把color资源和其他简单类型资源一起放入一个<resources>元素下。

 

文件位置:

res/values/colors.xml

文件名可随意指定。<color>元素的名称name将被用作资源ID

 

资源引用:

Java代码:R.color.color_name

XML代码:@[package:]color/color_name

 

语法:

<?xml version="1.0" encoding="utf-8"?> 

<resources> 

    <color 

        name="color_name" 

        >hex_color</color> 

</resources>


元素:

<resources>

必填项必须是根节点。

无属性。

<color>

十六进制表示的颜色值。如上所述。

属性:

name

String类型。颜色的名称,用作资源ID

 

示例:

存放在res/values/colors.xmlXML文件:

<?xml version="1.0" encoding="utf-8"?> 

<resources> 

   <color name="opaque_red">#f00</color> 

   <color name="translucent_red">#80ff0000</color> 

</resources>

以下应用程序代码取出color资源:

Resources res = getResources(); 

int color = res.getColor(R.color.opaque_red);

以下布局(layoutXMLcolor资源用于属性:

<TextView 

    android:layout_width="fill_parent" 

    android:layout_height="wrap_content" 

    android:textColor="@color/translucent_red" 

    android:text="Hello"/>

 



  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package com.example.dzy; import android.app.Dialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import java.io.InputStream; public class Fragment_1 extends Fragment { private ImageView imageView_1,imageView_2; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_shouye, container, false); imageView_1=(ImageView)view.findViewById(R.id.image_show1); imageView_1.setImageBitmap(bitmap); return view; } Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.show1); bigImageLoader(bitmap); //方法里直接实例化一个imageView不用xml文件,传入bitmap设置图片 private void bigImageLoader(Bitmap bitmap){ final Dialog dialog = new Dialog(getActivity()); ImageView image = new ImageView(getContext()); image.setImageBitmap(bitmap); dialog.setContentView(image); //将dialog周围的白块设置为透明 dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); //显示 dialog.show(); //点击图片取消 image.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ dialog.cancel(); } }); } }这段代码应如何修改
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值