當前位置:首頁 » 安卓系統 » android透明層

android透明層

發布時間: 2022-05-19 20:25:34

① 請教android怎麼讓控制項背景透明

以Android Studio為例,步驟如下:

1、直接打開相關窗口,在Android-app-res-layout的空白處點擊滑鼠右鍵並選擇New-Layoutresource file。

② android編程如何把現有的背景圖片設置成透明的

方法一:
只要在配置文件內activity屬性配置內加上

android:theme="@android:style/Theme.Translucent"

就好了。

這樣就調用了android的透明樣式!
方法二:
先在res/values下建colors.xml文件,寫入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>

<resources>

<colornamecolorname="transparent">#9000</color>

</resources>
這個值設定了整個界面的透明度,為了看得見效果,現在設為透明度為56%(9/16)左右。

③ android中怎麼把一個圖片設置透明化。

直接用一下代碼可以讓圖片變得透明,具體效果自己看看吧:

java">
/**


*圖片透明度處理

*

*@paramsourceImg

*原始圖片

*@paramnumber

*透明度

*@return

*/

publicstaticBitmapsetAlpha(BitmapsourceImg,intnumber){

int[]argb=newint[sourceImg.getWidth()*sourceImg.getHeight()];

sourceImg.getPixels(argb,0,sourceImg.getWidth(),0,0,sourceImg.getWidth(),sourceImg.getHeight());

//獲得圖片的ARGB值

number=number*255/100;

for(inti=0;i<argb.length;i++){

argb=(number<<24)|(argb&0x00FFFFFF);

//修改最高2位的值

}

sourceImg=Bitmap.createBitmap(argb,sourceImg.getWidth(),sourceImg.getHeight(),Config.ARGB_8888);

returnsourceImg;

}

④ 怎樣將android控制項背景設置成透明

1、打開安卓的配置文件。

2、只需要在配置文件中把需要設置為透明的activity的樣式設置為android:theme="@android:style/Theme.Translucent"

3、這樣就可以把背景設置為透明。

⑤ android 如何把一個 RelativeLayout或ImageView背景設為透明

設置背景為透明
1、設置背景為透明
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:background="@android:color/transparent"/><!--#00000000-->也可以設置顏色值,前兩位為透明度
2、設置背景透明度
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"/>
相應的也可以在java代碼中設置透明

⑥ android怎麼把activity的最底層view的背景設為透明

android設置背景色為透明
方法一:
只要在配置文件內activity屬性配置內加上
android:theme="@android:style/Theme.Translucent"
就好了。
這樣就調用了android的透明樣式!
方法二:
先在res/values下建colors.xml文件,寫入:

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

<resources>

<colorname="transparent">#9000</color>

</resources>

這個值設定了整個界面的透明度,為了看得見效果,現在設為透明度為56%(9/16)左右。

再在res/values/下建styles.xml,設置程序的風格

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

<resources>

<stylename="Transparent">

<itemname="android:windowBackground">@color/transparent</item>

<itemname="android:windowIsTranslucent">true</item>

<itemname="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>

</style>

</resources>

最後一步,把這個styles.xml用在相應的Activity上。即在AndroidManifest.xml中的任意<activity>標簽中添加

android:theme="@style/transparent"

如果想設置所有的activity都使用這個風格,可以把這句標簽語句添加在<application>中。

⑦ 如何設置Android中控制項的顏色透明度

Android中設置ImageView控制項的圖片的透明度應該調用View的api,以下為示例:
1、用android系統的透明效果
Java代碼
android:background="@android:color/transparent"
例如
設置按鈕
Java代碼
<Button
android:background="@android:color/transparent"
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
/>
2、用ARGB來控制
Java代碼
半透明<Button
android:background="#e0000000"
/>
透明<Button
android:background="#00000000"
/>
3、設置alpha
Java代碼
View
v
=
findViewById(R.id.content);
v.getBackground().setAlpha(100);
說明:
0~255透明度值,0表示完全不透明,255表示完全透明。

⑧ android透明區域點擊穿透怎麼實現

一個解決方法是,可以將這些耗時的操作放到recyclerview.setAdapter(adapter)之前運行,運行完後再將需要的參數傳入Adapter里,此處重寫一個adapter類繼承Adapter就可以了。解決後運行,滑動恢復了流暢。。

⑨ android中怎樣把背景透明

實現方式一(使用系統透明樣式)
通過配置 Activity 的樣式來實現,在 AndroidManifest.xml 找到要實現透明效果的 Activity,在 Activity 的配置中添加如下的代碼設置該 Activity 為透明樣式,但這種實現方式只能實現純透明的樣式,無法調整透明度,所以這種實現方式有一定的局限性,但這種方式實現簡單。
android:theme="@android:style/Theme.Translucent"

<activity
android:name="cn.sunzn.transact.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

實現方式二(使用自定義透明樣式)
這種方式的實現同樣要配置 Activity 的樣式,只不過這里的樣式是我們自定義的。具體實現過程如下:
1 在 res/values/color.xml 文件下加入一個透明顏色值,這里的 color 參數,是兩位數一個單位,前兩位數是透明度,後面每兩位一對是16進制顏色數字,示例中為白色。
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="translucent_background">#80000000</color>

</resources>

2 在 res/values/styles.xml 文件中加入一個自定義樣式,代碼如下。

<!-- item name="android:windowBackground" 設置背景透明度及其顏色值 -->
<!-- item name="android:windowIsTranslucent" 設置當前Activity是否透明-->
<!-- item name="android:windowAnimationStyle" 設置當前Activity進出方式-->
<style name="translucent">
<item name="android:windowBackground">@color/translucent_background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>

3 在 AndroidManifest.xml 找到要實現透明的 Activity,在想要實現透明的 Activity 中配置其屬性,代碼如下;也可在該 Activity 的 onCreat() 方法中調用 setTheme(R.style.translucent) 來實現。

<activity
android:name="cn.sunzn.transact.MainActivity"
android:label="@string/app_name"
android:theme="@style/translucent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

⑩ android studio activity怎麼設置透明背景

Android studio在Manifest.xml中找到對應的activity在裡面加上android:theme="@android:style/Theme.Translucent"即可背景透明,如果還想取消標題欄和全屏的畫可以將style/改為Theme.Translucent.NoTitleBar.Fullscreen

熱點內容
vc6編譯操作 發布:2025-08-20 23:16:14 瀏覽:869
時統伺服器搭建 發布:2025-08-20 23:15:58 瀏覽:907
c語言單字元 發布:2025-08-20 23:15:12 瀏覽:70
outlook發送伺服器地址在哪裡 發布:2025-08-20 23:06:13 瀏覽:1000
c語言培訓心得 發布:2025-08-20 23:02:20 瀏覽:46
如何打開raw伺服器鏡像 發布:2025-08-20 22:48:13 瀏覽:76
1分鍾造解壓神器 發布:2025-08-20 22:46:28 瀏覽:378
雲伺服器搭建spark 發布:2025-08-20 22:41:19 瀏覽:36
好用免費雲伺服器 發布:2025-08-20 22:16:44 瀏覽:609
傲慢與偏見ftp 發布:2025-08-20 22:11:15 瀏覽:904