小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

自定義Toast

 杰出天下 2012-09-26

最近開發(fā)的一個Android小程序,使用Toast給用戶提示信息,但是使用系統(tǒng)默認的Toast顯示的字體偏小,于是通過自定義布局文件修改Toast字體大小,同時為了使自定義的Toast與系統(tǒng)默認的Toast樣式一致,給自定義視圖進行了一定的修飾,效果如下:

Eclipse中項目結(jié)構(gòu):

各個文件代碼如下:

MainActivity.java

  1. public class MainActivity extends Activity  
  2. {  
  3.     @Override  
  4.     public void onCreate(Bundle savedInstanceState)  
  5.     {  
  6.         super.onCreate(savedInstanceState);  
  7.         setContentView(R.layout.main);  
  8.         initToast();  
  9.     }  
  10.   
  11.     private void initToast()  
  12.     {  
  13.         View toastRoot = getLayoutInflater().inflate(R.layout.toast, null);  
  14.         TextView message = (TextView) toastRoot.findViewById(R.id.message);  
  15.         message.setText("My Toast");  
  16.   
  17.         Toast toastStart = new Toast(this);  
  18.         toastStart.setGravity(Gravity.BOTTOM, 010);  
  19.         toastStart.setDuration(Toast.LENGTH_LONG);  
  20.         toastStart.setView(toastRoot);  
  21.         toastStart.show();  
  22.     }  
  23.   
  24. }  

toast.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas./apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical"  
  6.     android:background="@drawable/toast_frame"  
  7.     >  
  8.     <TextView   
  9.         android:id="@+id/message"  
  10.         android:layout_width="wrap_content"  
  11.         android:layout_height="wrap_content"  
  12.         android:layout_weight="1"  
  13.         android:textAppearance="@style/TextAppearance.Small"  
  14.         android:textColor="@color/bright_foreground_dark"  
  15.         android:shadowColor="#BB000000"  
  16.         android:shadowRadius="2.75"  
  17.         />  
  18. </LinearLayout>  

colors.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <color name="bright_foreground_dark">#ffffffff</color>  
  4. </resources>  

styles.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <style name="TextAppearance">  
  4.         <item name="android:textColor">@android:color/primary_text_dark</item>  
  5.         <item name="android:textColorHighlight">#FFFF9200</item>  
  6.         <item name="android:textColorHint">#808080</item>  
  7.         <item name="android:textColorLink">#5C5CFF</item>  
  8.         <item name="android:textSize">16sp</item>  
  9.         <item name="android:textStyle">normal</item>  
  10.     </style>  
  11.     <style name="TextAppearance.Small">  
  12.         <item name="android:textSize">20sp</item>  
  13.         <item name="android:textStyle">normal</item>  
  14.         <item name="android:textColor">@android:color/secondary_text_light</item>  
  15.     </style>  
  16. </resources>  
  1. <span style="font-size:16px;">源碼下載地址:</span><a href="http://download.csdn.net/detail/coolszy/4013139"><span style="font-size:16px;">http://download.csdn.net/detail/coolszy/4013139</span></a> 

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

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多