久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Android有趣的全透明效果--Activity及Dialog的全透明(附android...

 software1 2010-12-22
1.Activity全透明
同學(xué)zzm給了這個(gè)有趣的代碼,現(xiàn)在公布出來,。
先在res/values下建colors.xml文件,寫入:
<? xml   version = "1.0"   encoding = "UTF-8" ?>   
< resources >   
    < color   name = "transparent" > #9000 </ color >   
</ resources >  
這個(gè)值設(shè)定了整個(gè)界面的透明度,,為了看得見效果,,現(xiàn)在設(shè)為透明度為56%(9/16)左右。
再在res/values/下建styles.xml,設(shè)置程序的風(fēng)格
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="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>
最后一步,,把這個(gè)styles.xml用在相應(yīng)的Activity上,。即在AndroidManifest.xml中的任意<activity>標(biāo)簽中添加
android:theme = "@style/transparent"
如果想設(shè)置所有的activity都使用這個(gè)風(fēng)格,可以把這句標(biāo)簽語句添加在<application>中,。
最后運(yùn)行程序,,哈哈,是不是發(fā)現(xiàn)整個(gè)界面都被蒙上一層半透明了,。最后可以把背景色#9000換成#0000,,運(yùn)行程序后,就全透明了,,看得見背景下的所有東西可以卻都操作無效,。呵呵....
2.Dialog全透明
1.準(zhǔn)備保留邊框的全透明素材如下圖:
 
2.在values中新建一styles.xml文件,內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="TANCStyle" parent="@android:style/Theme.Dialog">
        <!-- 更換背景圖片實(shí)現(xiàn)全透明 -->
        <item name="android:windowBackground">@drawable/panel_background_sodino1</item>
        <!-- 屏幕背景不變暗 -->
        <item name="android:backgroundDimEnabled">false</item>
        <!-- 更改對(duì)話框標(biāo)題欄 -->
        <item name="android:windowTitleStyle">@style/TitleStyle</item>
    </style>
    <style name="TitleStyle" parent="@android:style/DialogWindowTitle">
        <item name="android:textAppearance">@style/TitleText</item>
    </style>
    <style name="TitleText" parent="@android:style/TextAppearance.DialogWindowTitle">
        <!-- 設(shè)置Dialog標(biāo)題欄文字顏色,。 -->
        <item name="android:textColor">#000</item>
    </style>
</resources>
3.在layout文件夾下新建一文件句為main_dialog.xml,,內(nèi)容如下:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="UTF-8"?> 
<RelativeLayout xmlns:android="http://schemas./apk/res/android
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#0000"> 
    <ScrollView android:id="@+id/ScrollView01" 
        android:layout_width="wrap_content" 
        android:layout_height="200px" 
        android:layout_below="@+id/ImageView01" 
        android:background="#0000"> 
        <TextView android:id="@+id/TextView01" 
            android:text="SodinoText" 
            android:textColor="#f000" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="#0000" 
        ></TextView> 
    </ScrollView> 
    <Button android:id="@+id/btnCancel" 
        android:layout_below="@id/ScrollView01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:text="Cancel"> 
    </Button> 
</RelativeLayout> 
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas./apk/res/android"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background="#0000">
 <ScrollView android:id="@+id/ScrollView01"
  android:layout_width="wrap_content"
  android:layout_height="200px"
  android:layout_below="@+id/ImageView01"
  android:background="#0000">
  <TextView android:id="@+id/TextView01"
   android:text="SodinoText"
   android:textColor="#f000"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="#0000"
  ></TextView>
 </ScrollView>
 <Button android:id="@+id/btnCancel"
  android:layout_below="@id/ScrollView01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  android:text="Cancel">
 </Button>
</RelativeLayout>
4.Activity代碼如下:
view plaincopy to clipboardprint?
package lab.sodino.tanc;  
import android.app.Activity;  
import android.app.Dialog;  
import android.os.Bundle;  
import android.view.View;  
import android.widget.Button;  
import android.widget.TextView;  
public class TANCAct extends Activity {  
    /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.main);  
        Button btnShow = (Button) findViewById(R.id.btnShow);  
        btnShow.setOnClickListener(new Button.OnClickListener() {  
            public void onClick(View view) {  
                showTANC(  
                        "This is my custom dialog box",  
                        "TextContent\nWhen a dialog is requested for the first time, Android calls onCreateDialog(int)  from your Activity, which is where you should instantiate the Dialog. This callback method is passed the same ID that you passed to showDialog(int). After you create the Dialog, return the object at the end of the method.",  
                        "            }  
        });  
    }  
    private void showTANC(String header, String content, String url) {  
        final Dialog dialog = new Dialog(this, R.style.TANCStyle);  
        dialog.setContentView(R.layout.main_dialog);  
        dialog.setTitle(header);  
        dialog.setCancelable(true);  
        TextView textView01 = (TextView) dialog.findViewById(R.id.TextView01);  
        textView01.setText(content + content + content);  
        Button btnCancel = (Button) dialog.findViewById(R.id.btnCancel);  
        btnCancel.setOnClickListener(new Button.OnClickListener() {  
            public void onClick(View view) {  
                dialog.cancel();  
            }  
        });  
        dialog.show();  
    }  

package lab.sodino.tanc;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class TANCAct extends Activity {
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Button btnShow = (Button) findViewById(R.id.btnShow);
  btnShow.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View view) {
    showTANC(
      "This is my custom dialog box",
      "TextContent\nWhen a dialog is requested for the first time, Android calls onCreateDialog(int)  from your Activity, which is where you should instantiate the Dialog. This callback method is passed the same ID that you passed to showDialog(int). After you create the Dialog, return the object at the end of the method.",
      "
   }
  });
 }
 private void showTANC(String header, String content, String url) {
  final Dialog dialog = new Dialog(this, R.style.TANCStyle);
  dialog.setContentView(R.layout.main_dialog);
  dialog.setTitle(header);
  dialog.setCancelable(true);
  TextView textView01 = (TextView) dialog.findViewById(R.id.TextView01);
  textView01.setText(content + content + content);
  Button btnCancel = (Button) dialog.findViewById(R.id.btnCancel);
  btnCancel.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View view) {
    dialog.cancel();
   }
  });
  dialog.show();
 }
}
最后效果圖:
 
另附 android系統(tǒng)自帶圖標(biāo)大全(1.5 1.6 2.1)
 
本文來自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/sodino/archive/2010/08/18/5822147.aspx

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多