Ⅰ android UI中添加一張圖片如何將這張圖片中某一部分設為透明的
讓ui設計師給你做圖做成那樣。我一般都是這樣的。或者你要麻煩一點你就去了解一下caves畫筆(不知道我是否拼寫錯誤)估計那玩意可以把你的imageview里的某張圖片的一部分設置透明度,我沒用過,看人用過。
Ⅱ 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的背景透明,只需在只要在配置文件內activity屬性配置內加上android:theme="@android:style/Theme.Translucent"就好了。
但是想要多方面的設置theme的話,就要在values里設置風格先:
加透明:
先在res/values下建colors.xml文件,寫入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>
<resources>
<colornamecolorname="transparent">#9000</color><!--透明度-->
</resources>
這個值設定了整個界面的透明度,為了看得見效果,現在設為透明度為56%(9/16)左右。
透明度可以用#9000值調,將這個值(ARGB)改變,就會有不同效果的透明度。
再在res/values/下建styles.xml,設置程序的風格
<?xmlversionxmlversion="1.0"encoding="utf-8"?>
<resources>
<stylenamestylename="Transparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
加了@+android:style/Animation.Translucent這句的時候就會顯示出此activity會有動畫切換效果
最後一步,把這個styles.xml用在相應的Activity上。即在AndroidManifest.xml中的任意標簽中添加 android:theme="@style/transparent"
如果要設置所有的activity都使用這個風格,就把這句標簽語句添加在中。
Ⅳ 請教android怎麼讓控制項背景透明
以Android Studio為例,步驟如下:
1、直接打開相關窗口,在Android-app-res-layout的空白處點擊滑鼠右鍵並選擇New-Layoutresource file。
Ⅳ 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中,如何用canvas繪制透明
Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);然後用canvas畫這個buffer看看
Ⅶ 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 如何把一個 RelativeLayout或ImageView背景設為透明
在RelativeLayout或ImageView屬性中設置android:background=「#00000」 透明色的色值就ok
Ⅸ 如何讓android 的activity變成完全透明的
將activity變為半透明的對話框可以從兩個方面來考慮:對話框和半透明。 1、在定義Activity時指定Theme.Dialog主題就可以將Activity設置為對話框風格。 2、通過修改Theme.Dialog主題的android:windowBackground屬性值可以改變Activity的背景圖像。如果背景圖像使用半透明的圖像,則Activity就好變成半透明的對話框。為了修改android:windowBackground屬性,可以定義一個新的主題,該主體繼承自Theme.Dialog,代碼如下: (1)在res/values下創建兩個xml文件,一個為主題風格資源dialog_styles.xml, 一個為顏色資源dialog_colors.xml。 dialog_styles.xml,主題風格名為 dialog_translucent dialog_colors.xml 2()在AndroidManifest.xml為Activity指定自定義的主題, android:theme="@style/dialog_translucent" 代碼如下: