久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

添加不透明的“陰影"(大綱)到 Android TextView

Add opaque quot;shadowquot; (outline) to Android TextView(添加不透明的“陰影(大綱)到 Android TextView)
本文介紹了添加不透明的“陰影"(大綱)到 Android TextView的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個

但它看起來像這樣:

您可以看到當前陰影模糊并逐漸消失.我想要一個堅實的、不透明的陰影.但是怎么做呢?

我當前的代碼是:

解決方案

我嘗試了其他帖子中的所有技巧、技巧和竅門,例如

I have a TextView in my Activity to which I want to add a shadow. It is supposed to look like in OsmAnd (100% opaque):

But it looks like this:

You can see that the current shadow is blurred and fades away. I want a solid, opaque shadow. But how?

My current code is:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/speedTextView"
    android:text="25 km/h"

    android:textSize="24sp"
    android:textStyle="bold"
    android:textColor="#000000"
    android:shadowColor="#ffffff"
    android:shadowDx="0"
    android:shadowDy="0"
    android:shadowRadius="6"
/>

解決方案

I tried all the hacks, tips and tricks in the other posts like here, here and here.

None of them works that great or looks so good.

Now this is how you really do it (found in the Source of the OsmAnd app):

You use a FrameLayout (which has the characteristic of laying its components over each other) and put 2 TextViews inside at the same position.

MainActivity.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:background="#445566">

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_weight="1">

        <TextView
            android:id="@+id/textViewShadowId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:textSize="36sp"
            android:text="123 ABC" 
            android:textColor="#ffffff" />

        <TextView
            android:id="@+id/textViewId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:textSize="36sp"
            android:text="123 ABC"
            android:textColor="#000000" />
    </FrameLayout>

</LinearLayout>

And in the onCreate method of your activity you set the stroke width of the shadow TextView and change it from FILL to STROKE:

import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
    
public class MainActivity extends AppCompatActivity {    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        //here comes the magic
        TextView textViewShadow = (TextView) findViewById(R.id.textViewShadowId);
        textViewShadow.getPaint().setStrokeWidth(5);
        textViewShadow.getPaint().setStyle(Paint.Style.STROKE);
    }
}

The result looks like this:

這篇關于添加不透明的“陰影"(大綱)到 Android TextView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 久久国产99 | 成人激情免费视频 | 日韩久久久久久久久久久 | 综合久久久 | 一级a性色生活片久久毛片 一级特黄a大片 | 99免费精品视频 | 精品一区二区久久久久久久网站 | 美女久久久久久久 | 午夜视频在线观看网址 | 天天干天天操 | 在线视频亚洲 | 国产免费视频在线 | 在线欧美一区二区 | 日韩一区欧美一区 | 国产成人99久久亚洲综合精品 | 日韩精品一区二区三区视频播放 | 9191在线播放 | 91国产在线视频在线 | 欧美一区二区三区 | 中文字幕在线网 | 日韩欧美三级在线 | 欧美情趣视频 | 国产精品久久久久久久久久妞妞 | 波多野结衣电影一区 | 欧美日韩国产精品激情在线播放 | 日本午夜在线视频 | 国产精品一区在线 | 日韩欧美二区 | 成人免费看片网 | 国外成人在线视频 | 青草青草久热精品视频在线观看 | 欧美性生活一区二区三区 | 99精品99| 国产精品久久久久国产a级 欧美日韩国产免费 | 麻豆av片 | 自拍偷拍中文字幕 | 欧美一区免费 | 欧洲精品久久久久毛片完整版 | 欧美成人一区二区 | 日韩中文字幕网 | 一级做受毛片免费大片 |