當前位置:首頁 » 安卓系統 » android設置陰影

android設置陰影

發布時間: 2023-07-03 03:34:05

❶ Android 去掉Button陰影效果

Android系統5.0之後系統的默認button控制項都會有一個陰影,UI設計上一般都不會有這個效果,所以只能想辦法去掉。

在Application使用的主題中加入以下屬性即可

在Activity使用的Theme中加入以下屬性即可

可以參考

❷ Android 特殊陰影效果的實現 & 點九圖的妙用

若是納尺直接將陰影和雪塊平台一起切圖,則會發生圖片難以定位,及圖片拉伸的問題

雖然可以通過 比例大法 解決,但是比較復雜
直接實現陰影似乎復雜度也比較高

可游氏以將描邊及陰影一起切圖洞磨高,然後 製作成 點九圖,(見《Android Studio 製作點九圖》) ,當做背景填充即可

❸ 怎麼為android控制項邊緣添加陰影

為控制項設置一個有陰影感的背景圖片即可,可以使用shape


在自定義shape中增加一層或多層,並錯開,即可顯示陰影效果。為增加立體感,按鈕按下的時候,只設置一層。我們可以通過top, bottom, right 和 left 四個參數來控制陰影的方向和大小



//自定義兩種陰影效果

第一種

java"><?xmlversion="1.0"encoding="utf-8"?>

<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:state_pressed="true">
<layer-list>
<itemandroid:left="4dp"android:top="4dp">
<shape>
<solidandroid:color="#ff58bb52"/>
<cornersandroid:radius="30dip"/>
</shape>
</item>
</layer-list>
</item>
<item>
<layer-list>
<!--第一層-->
<itemandroid:left="4dp"android:top="4dp">
<shape>
<solidandroid:color="#66000000"/>
<cornersandroid:radius="30dip"/>
<!--描邊-->
<strokeandroid:width="1dp"android:color="#ffffffff"/>
</shape>
</item>
<!--第二層-->
<itemandroid:bottom="4dp"android:right="4dp">
<shape>
<solidandroid:color="#ff58bb52"/>
<cornersandroid:radius="30dip"/>
<!--描邊-->
<strokeandroid:width="1dp"android:color="#ffffffff"/>
</shape>
</item>
</layer-list>
</item>
</selector>


第二種

<?xmlversion="1.0"encoding="utf-8"?>

<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<!--點擊之後-->
<itemandroid:state_pressed="true">
<layer-list>
<itemandroid:left="4dp"android:top="4dp">
<shape>
<solidandroid:color="#ff58bb52"/>
<cornersandroid:radius="3dp"/>
</shape>
</item>
</layer-list>
</item>
<!--正常狀態-->
<item>
<layer-list>
<!--第一層-->
<itemandroid:left="2dp"android:top="2dp">
<shape>
<solidandroid:color="#66000000"/>
<cornersandroid:radius="3dp"/>
</shape>
</item>
<!--第二層-->
<itemandroid:bottom="4dp"android:right="4dp">
<shape>
<solidandroid:color="#ff58bb52"/>
<cornersandroid:radius="3dp"/>
</shape>
</item>
<!--第三層-->
<itemandroid:bottom="6dp"android:right="6dp">
<shape>
<solidandroid:color="#ffcccccc"/>
<cornersandroid:radius="3dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>

設置後的效果圖如下

❹ android 怎麼改變list view頂部滑動陰影顏色

需要說明的是,在正常默認情況下都是選擇Item橙黃色,點擊Item橙黃色,但是如果你設置了Item整體布局的背景色 android:background="#000000"則,你的上面兩個都會不起作用,導致你selected了Item看不出來是否選擇了。

那如何改橙黃色為綠色呢?????
step1:list_item.xml中的代碼:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:orientation="vertical"
android:background="@drawable/list_item_bg"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"

>
<TextView
.....
/>
<ImageView
....
/>
</RelativeLayout>
</LinearLayout>

❺ android 上陰影效果怎麼做

設置陰影需要按照以下步驟:
1、設置eleavation值;
2、添加一個背景或者outline。
可以在xml中通過定義一個背景來設置outline:
<TextView
android:id="@+id/myview"
...
android:elevation="2dp"
android:background="@drawable/myrect" />
<!-- res/drawable/myrect.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#42000000" />
<corners android:radius="5dp" />
</shape>

也可以通過代碼來創建一個outline:
/* Get the size of the shape from resources. */
int shapeSize = getResources().getDimensionPixelSize(R.dimen.shape_size);

/* Create a circular outline. */
mOutlineCircle = new Outline();
mOutlineCircle.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 2);

/* Create a rectangular outline. */
mOutlineRect = new Outline();
mOutlineRect.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 10);

❻ android 圓角邊框 陰影邊框怎麼設置

所謂添加陰影,就是兩個畫布從重疊,上方的畫布小於下方的畫布,陰影顏色為下方的畫布的顏色。
item 中shape 的屬性 (rectangle:矩形;line:線性;oval:橢圓;ring:環形),默認為矩形
corners //設置圓角幅度,必須是在shape=rectangle的時候,corners才有效
<corners
Android:radius="dimension" //全部的圓角半徑
android:topLeftRadius="dimension" //左上角的圓角半徑
android:topRightRadius="dimension" //右上角的圓角半徑
android:bottomLeftRadius="dimension" //左下角的圓角半徑
android:bottomRightRadius="dimension" /> //右下角的圓角半徑
eg:<corners android:radius="10dp" />
solid用以指定內部填充色
e.g:<solid android:color="color" />
gradient //定義漸變色,可以定義兩色漸變和三色漸變,及漸變樣式
linear(線性漸變)、radial(放射性漸變)、sweep(掃描式漸變), 在構造放射性漸變時,要加上android:gradientRadius屬性(漸變半徑),即必須指定漸變半徑的大小才會起作用。
<gradient
android:type=["linear" | "radial" | "sweep"] //共有3中漸變類型
android:angle="integer" //漸變角度,必須為45的倍數,0為從左到右,90為從上到下
android:centerX="float" //漸變中心X的相當位置,范圍為0~1
android:centerY="float" //漸變中心Y的相當位置,范圍為0~1
android:startColor="color" //漸變開始點的顏色
android:centerColor="color" //漸變中間點的顏色,在開始與結束點之間
android:endColor="color" //漸變結束點的顏色
android:gradientRadius="float" //漸變的半徑,只有當漸變類型為radial時才有效
android:useLevel=["true" | "false"] /> //使用LevelListDrawable時就要設置為true。設為false時才有漸變效果
stroke //這是描邊屬性,可以定義描邊的寬度,顏色,虛實線等
<stroke
android:width="dimension" //描邊的寬度
android:color="color" //描邊的顏色 // 以下兩個屬性設置虛線
android:dashWidth="dimension" //虛線的寬度,值為0時是實線
android:dashGap="dimension" /> //虛線的間隔

❼ android 文字怎麼加陰影效果 怎麼無效

Android:shadowColor 陰影顏色

android:shadowDx 陰影的水平偏移量

android:shadowDy 陰影的垂直偏移量

android:shadowRadius 陰影的范圍

為了統一風格和代碼的復用,通常可以把這個樣式抽取放入到style.xml文件中


<TextView
style="@style/textstyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="字體樣式"
android:textSize="30sp"
android:textStyle="bold" />


樣式實現:

<?xmlversion="1.0"encoding="utf-8"?>

<resources>

<stylename="textstyle">

<itemname="android:shadowColor">#ff0000ff</item>

<itemname="android:shadowRadius">10</item>

<itemname="android:shadowDx">5</item>

<itemname="android:shadowDy">5</item>

</style>

</resources>



關於android文字陰影,共有四個屬性可以設置:

  • android:shadowColor :陰影顏色

  • android:shadowDx :陰影x方向位移

  • android:shadowDy :陰影y方向位移

  • android:shadowRadius :陰影的半徑

注意:陰影的半徑必須設,為0時沒有效果。

下面為改變x位移:

android:shadowColor="#ff000000" (前兩位為透明度)

android:shadowDx="2"

android:shadowDy="0"

android:shadowRadius="1"


效果(向右為正):

下面為改變y位移:

android:textColor="#979790"

android:shadowColor="#ff000000"

android:shadowDx="0"

android:shadowDy="2"

android:shadowRadius="1"

效果(向下為正):

下面改變半徑:

android:shadowDx="1"

android:shadowDy="1"

android:shadowRadius="1"

❽ Android自定義邊框加陰影

Android自定義邊框,可以設置任意邊框的角度和陰影。我下面分為 四個角度設置邊框、兩個角度設置邊框、半圓球設置邊框加兩層陰影等。

效果圖:

效果圖:

效果圖:

❾ 安卓怎麼在linearLayout或者其他一些組件底部添加陰影

有兩種解決方案:

1、使用9-patch 圖片,製作一個陰影部分的圖片,然後橫向拉伸即可


2、使用layer-list

  • 在res/drawable下,新建background_with_shadow.xml文件,該文件代碼如下:

<?xmlversion="1.0"encoding="utf-8"?>
<layer-listxmlns:android="http://schemas.android.com/apk/res/android">

<!--bottomshadow-->
<item>
<shapeandroid:shape="rectangle">
<!--fromtoptobottom-->
<gradient
android:angle="90"
android:centerColor="#bbbbbb"
android:endColor="#d5d5d5"
android:startColor="#a9a09d"/>
<cornersandroid:radius="5dp"/>
</shape>
</item>

<!--content-->
<itemandroid:bottom="2dp">
<shapeandroid:shape="rectangle">
<solidandroid:color="#50c1e9"/>
<cornersandroid:radius="5dp"/>
</shape>
</item>

</layer-list>
  • 使用background_with_shadow.xml文件

假設有bottom_shadow.xml文件,內容如下:

<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#bfbfbf">

<LinearLayout
android:layout_marginTop="40dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="vertical"
android:background="@drawable/background_with_shadow">
</LinearLayout>

<TextView
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="活動海報"/>

</LinearLayout>
  • 效果圖如下

熱點內容
微信電影源碼網站 發布:2025-02-06 18:55:21 瀏覽:933
本地建mysql資料庫 發布:2025-02-06 18:54:23 瀏覽:761
屏幕看不清了如何輸密碼 發布:2025-02-06 18:51:14 瀏覽:332
手機開腳本買個什麼配置的 發布:2025-02-06 18:45:59 瀏覽:111
python代碼輸入 發布:2025-02-06 18:32:35 瀏覽:562
易語言上傳ftp文件夾 發布:2025-02-06 18:31:09 瀏覽:73
仿qq源碼java 發布:2025-02-06 18:24:06 瀏覽:424
阿里雲訪問mysql資料庫 發布:2025-02-06 18:17:57 瀏覽:789
原神遊戲伺服器ip 發布:2025-02-06 17:54:23 瀏覽:811
如何查筆記本電腦的真正配置 發布:2025-02-06 17:48:07 瀏覽:82