當前位置:首頁 » 安卓系統 » android控制項透明

android控制項透明

發布時間: 2022-07-06 01:28:37

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

設置Android中控制項的顏色透明度,可自由設置在layout里也可以在activity里
eclipse

1

#ff000000 此為16進制顏色代碼,
前2位ff為透明度,後6位為顏色值(000000為黑色,ffffff為白色,可以用ps等軟體獲取)。
2
透明度分為256階(0-255),計算機上用16進製表示為(00-ff)。透明就是0階,不透明就是255階,如果50%透明就是127階(256的一半當然是128,但因為是從0開始,所以實際上是127)。
3
10進制的255換算成16進制是ff,127換算成16進制是7f,#7f000000 代表50%透明度的黑色。 (寫成#50000000當然是不行的)進制轉換可使用win7自帶計算器(轉為科學型)。例:25%透明度的一種紅色「#3ff70000

㈡ android怎麼將彈出窗口透明

1. 在res/values 下建立color.xml
<resources>
<color name="transparent_background">#80ffffff</color>
</resources>
PS: #80是透明度的值(即80%透明),ffffff是顏色值(為黑色)
2. 在res/values下建立style.xml
<resources> <style name="Transparent" parent="android:style/Theme.Dialog"> <item name="android:windowBackground">@color/transparent_background</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item> </style></resources>
PS: parent="android:style/Theme.Dialog" 是將activity設置為彈出式窗口
3. 在AndroidManifest.xml中找到要彈出的activity,加入theme:
<activity android:name="ActivityName" android:theme="@style/Transparent" />完成上面設置後,你的activity就已經是透明的了,但是該Activity中的控制項還沒有透明,如果還需要控制項透明,則需要在該activity的代碼中加入如下代碼:
//設置activity中的控制項透明 Window window = getWindow(); WindowManager.LayoutParams wl = window.getAttributes(); wl.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; wl.alpha=0.95f;//設置透明度,0.0為完全透明,1.0為完全不透明 window.setAttributes(wl);

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

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

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

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

㈣ Android中按鈕如何設置透明或半透明,求代碼

在main.xml裡面加入如下代碼,就可以Android中按鈕如何設置透明或半透明;
<Button
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
/>

㈤ android Button 怎麼把背景設置透明

Android控制項設置邊框,或者背景可以使用XML來配置,背景透明只需要設置solid 的值為 #00000000即可,前面兩位是透明度,後面6位是RGB顏色值,具體示例代碼如下:
1.在drawable新建一個 buttonstyle.xml的文件,內容如下:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 連框顏色值 --><item>
<shape>
<solid android:color="#ff0000" />
</shape>
</item>
<!-- 主體背景顏色值 -->
<item android:bottom="3dp" android:right="3dp">
<shape>
<solid android:color="#ffffff" />
<padding android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item>
</layer-list>

2.然後在布局文件裡面引入這個xml,示例代碼如下:
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:background="@drawable/buttonstyle" />

㈥ 如何讓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" 代碼如下:

㈦ 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自定義控制項怎麼設置不了背景透明!!!求解決方法

Android控制項設置邊框,或者背景可以使用XML來配置,背景透明只需要設置solid 的值為 #00000000即可,前面兩位是透明度,後面6位是RGB顏色值,具體示例代碼如下:
1.在drawable新建一個 buttonstyle.xml的文件,內容如下:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android=" //schemasandroidcom/apk/res/android">
<!-- 連框顏色值 --><item>
<shape>
<solid android:color="#ff0000" />
</shape>
</item>
<!-- 主體背景顏色值 -->
<item android:bottom="3dp" android:right="3dp">
<shape>
<solid android:color="#ffffff" />
<padding android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
</item>
</layer-list>

2.然後在布局文件裡面引入這個xml,示例代碼如下:
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:background="@drawable/buttonstyle" />

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

以Android Studio為例,步驟如下:

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

㈩ 請教大神,android中我需要在自定義控制項中繪制一個透明的小三角行

代碼:
public class MyView extends View {
//坐標軸原點的位置
private int xPoint=60;
private int yPoint=260;
//刻度長度
private int xScale=8; //8個單位構成一個刻度
private int yScale=40;
//x與y坐標軸的長度
private int xLength=380;
private int yLength=240;

private int MaxDataSize=xLength/xScale; //橫坐標 最多可繪制的點

private List<Integer> data=new ArrayList<Integer>(); //存放 縱坐標 所描繪的點

private String[] yLabel=new String[yLength/yScale]; //Y軸的刻度上顯示字的集合

private Handler mh=new Handler(){
public void handleMessage(android.os.Message msg) {
if(msg.what==0){ //判斷接受消息類型
MyView.this.invalidate(); //刷新View
}
};
};
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
for (int i = 0; i <yLabel.length; i++) {
yLabel[i]=(i+1)+"M/s";
}
new Thread(new Runnable() {
@Override
public void run() {
while(true){ //在線程中不斷往集合中增加數據
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(data.size()>MaxDataSize){ //判斷集合的長度是否大於最大繪制長度
data.remove(0); //刪除頭數據
}
data.add(new Random().nextInt(5)+1); //生成1-6的隨機數
mh.sendEmptyMessage(0); //發送空消息通知刷新
}
}
}).start();
}

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:628
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:357
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:75
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:300
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:788
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:338
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:204
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:801
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:357
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:583