久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 中文字幕一区在线 | 精久久久| 男人天堂午夜 | 日韩精品亚洲专区在线观看 | 国产欧美精品区一区二区三区 | 91视频精选 | 久久精点视频 | 狠狠躁夜夜躁人人爽天天高潮 | 天天插天天操 | 欧美不卡视频 | 国产成人综合在线 | 欧美三级电影在线播放 | 国产精品视频一区二区三区 | 琪琪午夜伦伦电影福利片 | 精品国产乱码久久久久久图片 | 国产精品激情 | 日韩欧美在线视频 | 欧美亚洲第一区 | 日韩精品一区中文字幕 | a在线观看免费 | 国产成人自拍一区 | www.久久精品视频 | 欧美一级免费片 | 日韩一区二区视频 | 午夜私人影院 | 久久看片| av午夜激情| 国产精品区二区三区日本 | 99精品免费在线观看 | 久草在线 | 99视频在线播放 | 97国产一区二区精品久久呦 | 欧美色视频免费 | 国产午夜精品一区二区三区在线观看 | 亚洲在线免费观看 | 亚洲精品区| 最新国产视频 | 中文字幕日韩一区 | 亚洲成人午夜电影 | 久久久久国产一区二区三区四区 | 毛片免费看 |