導航:首頁 > 操作系統 > androidrcolor

androidrcolor

發布時間:2023-01-21 11:01:20

『壹』 按鍵精靈安卓版如何獲取同個坐標不同顏色應該用那個顏色命令

你就是要判斷該坐標的顏色嗎?

Dim rColor

rColor = GetPixelColor(362, 441)

If rColor = "FF00FF" Then

//顏色1執行動作

ElseIf rColor = "0000FF" Then

//顏色2執行動作

ElseIf rColor = "000000" Then

//顏色3執行動作

Else

//顏色都不是執行動作

End If

『貳』 android怎麼調節屏幕色彩

Android中顏色是由透明度(alpha)和紅綠藍(RGB)定義的,兩種編碼方式:
1、八位十六進制數,例如FFEEDDCC,FF代表透明度(完全不透明),EE代表紅色(值越大紅色越深),DD代表綠色,CC代表藍色;
2、六位十六進制數,同上;
注意:六位編碼在XML中默認不透明(FF),在代碼中默認透明(00);在代碼中設置顏色,可以直接填八位的十六進制數值,如setTextColor(0xff00ff00);,也可以通過Color.rgb(int red, int green, int blue)和Color.argb(int alpha, int red, int green, int blue)來指定顏色。
如果在代碼中使用colors.xml中設置的顏色,可按如下方式獲取setTextColor(getResources().getColor(R.color.black));

『叄』 如何更改android設置背景顏色

通常來說,每個界面都對應一個activity。而在activity的View視圖中,可以在最外層容器去設置背景圖片或背景顏色。
在xml布局裡:
android:background="@drawable/img1"
或者
android:background="@color/white"
java代碼里,也可以設置

1
2
3

layout.setBackgroundColor(R.color.white);
layout.setBackgroundDrawable(drawable);
layout.setBackgroundResource(R.drawable.img1);

再者,系統默認的背景色是能過theme來控制的,就是說創建一個activity的背景色,如果在
AndroidManifest.xml文件里有設置如下:
android:theme="@android:style/Theme"
這樣設置activity的主題樣式,"@android:style/Theme"一般是系統默認的。這個不單是背景色,還有其它的樣式,具體可以在網上查一下android:theme的用法。

而"@android:style/Theme"的背景色就是黑色。

『肆』 安卓車機色彩設置參數

安卓車機色彩設置參數,具體操作如下。
一、AndroidColor設置
1、在xml文件中
想設置顏色直接設置background的屬性或者其他的color屬性。隨便設置一個顏色如#000,再點擊左邊的顏色方塊,彈出顏色選擇器選擇顏色
2、在java代碼中
①Color.parseColor("#000");
1
tvShow.setBackgroundColor(Color.parseColor("#000"));
【提示】可以在布局文件中配置好顏色值,然後把用「#」表示的顏色帶到java代碼中用
②Color.BLACK使用Color類自帶的顏色,不過都是一些基本色
tvShow.setBackgroundColor(Color.BLACK);
③定義Color資源文件,通過R.color.myColor引用

『伍』 Android R.color報錯

Clear一下Project
然後重新build一下試一試

『陸』 Android自定義字母導航欄

自定義側邊字母導航欄,根據實際字母高度進行顯示

先上效果圖

public class SlideBar extends View {

    //當前手指滑動到的位置

    private int choosedPosition = -1;

    //畫文字的畫筆

    private Paint paint;

    //單個字母的高度

    private float perTextHeight;

    //字母的字體大小

    private float letterSize;

    //字母的垂直間距

    private float letterGap;

    //字母圓形背景半徑

    private float bgRadius;

    private ArrayList<String> firstLetters = new ArrayList<>();

    //繪制點擊時的藍色背景

    private Paint backgroundPaint;

    private Context context;

    private OnTouchFirstListener listener;

    public RecyclerView getTiku_recycle_answer() {

        return tiku_recycle_answer;

    }

    public void setTiku_recycle_answer(RecyclerView tiku_recycle_answer) {

        this.tiku_recycle_answer = tiku_recycle_answer;

    }

    RecyclerView tiku_recycle_answer;

    public SlideBar(Context context) {

        this(context, null);

    }

    public SlideBar(Context context, AttributeSet attrs) {

        this(context, attrs, 0);

    }

    public SlideBar(Context context, AttributeSet attrs, int defStyleAttr) {

        super(context, attrs, defStyleAttr);

        this.context = context;

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SlideBar);

        //字母的字體大小

        letterSize = typedArray.getDimension(R.styleable.SlideBar_letter_size, DisplayUtils.sp2px(context, 10.0f));

        //每個字母的高

        perTextHeight = typedArray.getDimension(R.styleable.SlideBar_letter_height, DisplayUtils.dp2px(context, 10.0f));

        //字母垂直間距

        letterGap = typedArray.getDimension(R.styleable.SlideBar_letter_gap, DisplayUtils.dp2px(context, 6.0f));

        //字母垂直間距

        bgRadius = typedArray.getDimension(R.styleable.SlideBar_letter_bg_radius, DisplayUtils.dp2px(context, 8.0f));

        typedArray.recycle();

        init();

    }

    public void init() {

        //初始化畫筆

        paint = new Paint();

        paint.setAntiAlias(true);

        paint.setTextSize(letterSize);

        paint.setTypeface(Typeface.DEFAULT_BOLD);

        //初始化圓形背景畫筆

        backgroundPaint = new Paint();

        backgroundPaint.setAntiAlias(true);

        backgroundPaint.setColor(context.getResources().getColor(R.color.color_368FFF));

    }

    public void setFirstLetters(ArrayList<String> letters) {

        firstLetters.clear();

        firstLetters.addAll(letters);

        invalidate();

    }

    @Override

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int widthMode = MeasureSpec.getMode(widthMeasureSpec);  //獲取寬的模式

        int heightMode = MeasureSpec.getMode(heightMeasureSpec); //獲取高的模式

        int widthSize = MeasureSpec.getSize(widthMeasureSpec);  //獲取寬的尺寸

        int heightSize = MeasureSpec.getSize(heightMeasureSpec); //獲取高的尺寸

        int width = 0;

        int height;

        if (widthMode == MeasureSpec.EXACTLY) {

            //如果match_parent或者具體的值,直接賦值

            width = widthSize;

        } else {

            //如果其他模式,則指定一個寬度

            width = DisplayUtils.dp2px(getContext(), 20.0f);

        }

        //高度跟寬度處理方式一樣

        if (heightMode == MeasureSpec.EXACTLY) {

            height = heightSize;

        } else {

            float textHeight = perTextHeight;

            height = (int) (getPaddingTop() + textHeight * (firstLetters.size() + 1) + letterGap * (firstLetters.size() - 1) + getPaddingBottom());

        }

        if (height > tiku_recycle_answer.getMeasuredHeight()) {

            height = tiku_recycle_answer.getMeasuredHeight();

        }

        //保存測量寬度和測量高度

        setMeasuredDimension(width, height);

    }

    @Override

    protected void onDraw(Canvas canvas) {

        super.onDraw(canvas);

        for (int i = 0; i < firstLetters.size(); i++) {

            paint.setColor(i == choosedPosition ? Color.WHITE : context.getResources().getColor(R.color.color_368FFF));

            float x = (getWidth() - paint.measureText(firstLetters.get(i))) / 2;

            float y = (float) getHeight() / firstLetters.size();//每個字母的高度

            if (i == choosedPosition) {

                canvas.drawCircle((float) (getWidth() / 2), i * y + y / 2, bgRadius, backgroundPaint);

            }

            //垂直位置需要增加一個偏移量,上移兩個像素,因為根據計算得到的是baseline,將字母上移,使其居中在圓內

            canvas.drawText(firstLetters.get(i), x, (perTextHeight + y) / 2 + y * i-2, paint);

        }

    }

    //觸碰事件

    //按下,松開,拖動

    @Override

    public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:

            case MotionEvent.ACTION_MOVE:

                this.setBackgroundColor(context.getResources().getColor(android.R.color.transparent));

                float y = event.getY();

                //獲取觸摸到字母的位置

                choosedPosition = (int) y * firstLetters.size() / getHeight();

                //上滑超過邊界,顯示第一個

                if (choosedPosition < 0) {

                    choosedPosition = 0;

                }

                //下滑超過邊界,顯示最後一個

                if (choosedPosition >= firstLetters.size()) {

                    choosedPosition = firstLetters.size() - 1;

                }

                if (listener != null) {

                    //滑動A-Z字母聯動外層數據

                    listener.onTouch(firstLetters.get(choosedPosition));

                }

                break;

            case MotionEvent.ACTION_UP:

                this.setBackgroundColor(context.getResources().getColor(android.R.color.transparent));

                choosedPosition = -1;

                if (listener != null) {

                    //滑動A-Z字母聯動外層數據

                    listener.onRelease();

                }

                break;

        }

        //重繪

        invalidate();

        return true;

    }

    public void setFirstListener(OnTouchFirstListener listener) {

        this.listener = listener;

    }

    /**

    * OnTouchFirstListener 介面

    * onTouch:觸摸到了那個字母

    * onRelease:up釋放時中間顯示的字母需要設置為GONE

    */

    public interface OnTouchFirstListener {

        void onTouch(String firstLetter);

        void onRelease();

    }

}

<declare-styleable name="SlideBar">

    <attr name="letter_size" format="dimension" />

    <attr name="letter_height" format="dimension" />

    <attr name="letter_gap" format="dimension" />

    <attr name="letter_bg_radius" format="dimension" />

</declare-styleable>

xml中引入,我的是constraintlayout,具體設置看自己的布局

<com.answer.view.SlideBar

    android:id="@+id/slideBar"

    android:layout_width="@dimen/dp_20"

    android:layout_height="wrap_content"

    app:layout_constraintBottom_toBottomOf="@+id/tiku_recycle_answer"

    app:layout_constraintEnd_toEndOf="parent"

    app:layout_constraintStart_toStartOf="@+id/guide_answer"

    app:layout_constraintTop_toTopOf="@+id/tiku_recycle_answer"

    app:letter_bg_radius="@dimen/dp_8"

    app:letter_gap="@dimen/dp_6"

    app:letter_height="@dimen/dp_10"

    app:letter_size="@dimen/sp_10" />

private void handleSlideBarEvent() {

    List<QuesCommentSubjectiveStuBean> datas = .getDatas();//獲取處理後的數據,賦值給導航欄

    ArrayList<String> letters = new ArrayList<>();

    for (QuesCommentSubjectiveStuBean stuBean : datas) {

        if (letters.contains(stuBean.getFirstLetter())) {

            continue;

        }

        letters.add(stuBean.getFirstLetter());

    }

    slideBar.setFirstLetters(letters);

    slideBar.setTiku_recycle_answer(tiku_recycle_answer);

    slideBar.setFirstListener(new SlideBar.OnTouchFirstListener() {

        @Override

        public void onTouch(String firstLetter, float dy) {

            tv_first_letter.setVisibility(VISIBLE);

            tv_first_letter.setText(firstLetter);

            ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) tv_first_letter.getLayoutParams();

            //如果是第一個字母,修改提示框顯示位置

            layoutParams.topMargin = (int) dy + slideBar.getTop() - tv_first_letter.getMeasuredHeight() / 2;

            //異常情況,點擊最後一個字元,提示框顯示不全的場景,如果顯示位置超過屏幕,則靠底部顯示

            if ((int) dy + slideBar.getTop() + tv_first_letter.getMeasuredHeight() / 2 > tiku_recycle_answer.getBottom()) {

                layoutParams.topMargin = tiku_recycle_answer.getBottom() - tv_first_letter.getMeasuredHeight();

            }

            tv_first_letter.setLayoutParams(layoutParams);

            //滑動後移動到對應的位置,找到第一個匹配到首字母的學生,位移到此處

            int newPosition = -1;

            for (QuesCommentSubjectiveStuBean stuBean : datas) {

                if (firstLetter.equals(stuBean.getFirstLetter())) {

                    newPosition = datas.indexOf(stuBean);

                    break;

                }

            }

            //move時會多次觸發,此處只響應第一次

            if (newPosition != lastPosition) {

                lastPosition = newPosition;

                Lg.d(TAG, "questionComment-->--滑動導航欄跳轉到首字母:" + firstLetter);

                subJectLinearLayoutManager.scrollToPositionWithOffset(lastPosition, 0);

            }

        }

        @Override

        public void onRelease() {

            postDelayed(new Runnable() {

                @Override

                public void run() {

                    lastPosition = -1;

                    tv_first_letter.setVisibility(GONE);

                }

            }, 200);

        }

    });

}

5.一個小問題。

用於放大顯示選中字母的TextView在布局中,請設置為invisible,這樣在載入xml布局時,會對這個控制項進行測量和布局,只是不顯示,這樣我們才能獲得tv_first_letter.getMeasuredHeight(),如果設置為gone,不會進行測量,獲取的高度就為0,這樣在第一次顯示的時候就會有一個顯示位置跳動的異常。設置為invisible就可以解決這個問題,目的就是讓系統測量一下TextView的寬高,不想這么搞的話,在第4步之前手動測量一次也是可以的。

<TextView

    android:id="@+id/tv_first_letter"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_marginEnd="@dimen/dp_2"

    android:background="@mipmap/ic_bubble"

    android:fontFamily="sans-serif"

    android:gravity="center"

    android:text="C"

    android:textColor="@color/color_ffffff"

    android:textSize="@dimen/sp_18"

    android:visibility="invisible"

    app:layout_constraintEnd_toStartOf="@+id/guide_answer"

    app:layout_constraintTop_toTopOf="parent" />

『柒』 android怎樣自定義color文件

Android開發中顏色的自定義方法

1、使用Color類的常量,如:
int color = Color.BLUE; // 創建一個藍色 是使用Android提供的顏色 int color = Color.RED; int color = Color.WHITE; 2、通過ARGB構建,如:
int color = Color.argb ( 127, 255, 0, 255 ); // 半透明的紫色
其中第一個參數表示透明,0表示完全透明,255(ff)表示完全不透明;後三位分別代表RGB的值了。 3、使用XML資源文件來定義顏色
該方法擴展性好,便於修改和共享,如在values目錄下創建一個color.xml: <?xml version=」 1.0」 encoding=」utf -8」> <resources>
<color name=」mycolor」> #7fff00ff</color> </resources>
定義了一個名為mycolor的顏色,在別的地方就可以通過引用mycolor來獲取該顏色值,如textView定義中:
android:textColor= "@drawable/mycolor"
Java代碼中可以使用ResourceManager類中的getColor來獲取該顏色: int color = getResources().getColor(R.color.mycolor);
這與第二種方法得到的值是一樣的,getResources()方法返回當前活動Activity的ResourceManager類實例。
說明:XML定義方法接受6位和8位兩種表示法,而且開頭必須是#,8位定義時前兩位表示透明。 4、直接定義色值,如: int color = 0xff00ff00;
這種方法必須使用0x開頭,而不是用我們常用的#。與方法3不一樣,值也必須用8位表示 ,不接受6位的顏色表示。分組一下0x|ff|ff00ff,0x是代表顏色整數的標記,ff是表示透明度,ff00ff表示RGB顏色值。
=======================
補充一點Android布局中背景圖片的設置(編輯LinearLayout):
* 可以使用純色:android:background="@drawable/mycolor" (XML資源文件中定義的顏色)
* 也可使用圖片:android:background="@drawable/bg" (需要將一個名為bg.jpg或png的圖片拷貝到res/drawable-hdpi目錄下)

『捌』 android 顏色有色差 怎麼處理

Android 中有時出現色差,我碰到的情況是 Galaxy ACE4 中的白色和系統白色不同,所以顯示時候顏色不同,很難看。
我發現的問題是 Color.white, android.R.color.white, R.color.white 是不同的,具體區別和聯系還待測試。

解決方案 :
在代碼中,把出現色差出的view的背景顏色設為 android.R.color.white
view.setBackgroundColor(getResources().getColor(android.R.color.white));

閱讀全文

與androidrcolor相關的資料

熱點內容
組件注冊命令 瀏覽:760
安卓大屏導航用的是什麼運放 瀏覽:443
myandroidtools的備份 瀏覽:900
python爬蟲天氣預報 瀏覽:761
android70許可權管理 瀏覽:749
魔獸辛迪加是什麼伺服器 瀏覽:471
電腦文件夾排序怎麼自定義排序 瀏覽:41
android70機型 瀏覽:422
阿里程序員地位 瀏覽:183
js如何上傳大文件到伺服器地址 瀏覽:685
安卓系統2個卡怎麼切換 瀏覽:182
vivoy9s手機怎麼設置隱私相冊加密 瀏覽:158
android載入網路數據 瀏覽:119
tc語言入門編程 瀏覽:339
載入器app源碼大全 瀏覽:821
linux刷新hosts 瀏覽:620
cmd命令鍵盤 瀏覽:311
優盤空文件夾怎麼刪不掉 瀏覽:843
androidsetpixels 瀏覽:909
掃碼輔助接單平台源碼 瀏覽:781