当前位置:  编程技术>移动开发
本页文章导读:
    ▪splash screen制造的两种方法        splash screen制作的两种方法 1. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); // thread for displaying the SplashScreen Thread splashTread = new Thread() .........
    ▪ 动态兑现隐藏标题栏        动态实现隐藏标题栏 <? xml version = "1.0" encoding = "utf-8" ?>   <LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"       android:layout_width = "fill_parent"       android:layout_height.........
    ▪ googleMap的MapManager~自各儿一个小封装       googleMap的MapManager~~~自己一个小封装 public class MapManager { //==============================Singleton=========================================== private volatile static MapManager manager; private LocationManager lm; private MapContro.........

[1]splash screen制造的两种方法
    来源: 互联网  发布时间: 2014-02-18
splash screen制作的两种方法

1.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
 
    // thread for displaying the SplashScreen
    Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                int waited = 0;
                while(_active && (waited < _splashTime)) {
                    sleep(100);
                    if(_active) {
                        waited += 100;
                    }
                }
            } catch(InterruptedException e) {
                // do nothing
            } finally {
                finish();
                startActivity(new Intent("com.droidnova.android.splashscreen.MyApp"));
                stop();
            }
        }
    };
    splashTread.start();
}

 

就是闪屏的activity中 加入一个线程 然后其他主activity就可以了

2.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.splash);
  new Handler().postDelayed(new Runnable(){
      @Override
      public void run() {
        finish();
        startActivity(new Intent("com.droidnova.android.splashscreen.MyApp"));
      }
  }, _splashTime);
}

 


    
[2] 动态兑现隐藏标题栏
    来源: 互联网  发布时间: 2014-02-18
动态实现隐藏标题栏

<? xml version = "1.0" encoding = "utf-8" ?>  
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"  
    android:layout_width = "fill_parent"  
    android:layout_height = "fill_parent"  
    android:orientation = "vertical"  
    android:fadingEdgeLength = "0sp"  
    >  
 
    <LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"  
        android:id = "@+id/myTitleBarLayout"  
        android:layout_width = "fill_parent"  
        android:layout_height = "wrap_content"  
        android:orientation = "vertical"  
        >  
 
        <TextView  
            android:id = "@+id/myTitleBarTextView"  
            android:layout_width = "fill_parent"  
            android:layout_height = "wrap_content"  
            android:text = "@string/app_name"  
            android:paddingTop = "4dip"  
            android:paddingBottom = "4dip"  
            android:paddingLeft = "6dip"  
            android:textStyle = "bold"  
            android:shadowColor = "#BB000000"  
            android:shadowRadius = "3.0"  
            android:shadowDy = ".25"  
 
        />  
 
        <View  
            android:layout_width = "fill_parent"  
            android:layout_height = "1dip"  
            android:background = "#CCEEEEEE"  
            android:padding = "10dip"  
        />  
    </LinearLayout>  
 
    <ScrollView   xmlns:android = "http://schemas.android.com/apk/res/android"  
        android:layout_width = "fill_parent"  
        android:layout_height = "fill_parent"  
        android:layout_weight = "1"  
        >  
 
        <!-- Insert your regular layout stuff here -->  
 
        <Button android:id = "@+id/toggle_title_button"  
            android:layout_width = "wrap_content"  
            android:layout_height = "wrap_content"  
            android:text = "Toggle Title"  
        />  
    </ScrollView>  
</LinearLayout>  

然后

package com . test . HelloGridView ;  
 
import android . app . Activity ;  
import android . os . Bundle ;  
import android . view . View ;  
import android . view . Window ;  
import android . view . View . OnClickListener ;  
import android . widget . Button ;  
import android . widget . LinearLayout ;  
import android . widget . TextView ;  
 
public class HelloGridView extends Activity  
{  
    public void onCreate ( Bundle savedInstanceState )  
    {  
        requestWindowFeature ( Window . FEATURE_NO_TITLE );  
 
        super . onCreate ( savedInstanceState );  
        setContentView ( R . layout . main );  
 
        TextView tv = ( TextView ) this . findViewById ( R . id . myTitleBarTextView );  
        tv . setBackgroundColor ( 0xFF848284 );  
        tv . setTextColor ( 0xFFFFFFFF );  
 
        Button toggleTitleButton = ( Button ) this . findViewById ( R . id . toggle_title_button );  
 
        toggleTitleButton . setOnClickListener ( new OnClickListener ()  
                {  
                        @Override  
                        public void onClick ( View v )  
                        {  
                                LinearLayout ll = ( LinearLayout ) findViewById ( R . id . myTitleBarLayout );  
 
                                if ( ll . getVisibility () == View . GONE )  
                                {  
                                        ll . setVisibility ( View . VISIBLE );  
                                }  
                                else  
                                {  
                                        ll . setVisibility ( View . GONE );  
                                }  
                        }  
                });  
    }  
}  

 

有时候也可以

 

通过

private void updateFullscreenStatus ( bUseFullscreen )  
{    
    if ( bUseFullscreen )  
    {  
        getWindow (). addFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN );  
        getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_FORCE_NOT_FULLSCREEN );  
    }  
    else  
    {  
        getWindow (). addFlags ( WindowManager . LayoutParams . FLAG_FORCE_NOT_FULLSCREEN );  
        getWindow (). clearFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN );  
    }  
 
    m_contentView . requestLayout ();  
}  
通 过两种方法 就可以去掉状态栏和标题栏了这个用在游戏中比较好.,上述方法是通过标题栏实现的

3.通过主题实现隐藏状态栏和标 题栏

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

<application android:icon="@drawable/icon"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen">


    
[3] googleMap的MapManager~自各儿一个小封装
    来源: 互联网  发布时间: 2014-02-18
googleMap的MapManager~~~自己一个小封装
public class MapManager {

//==============================Singleton===========================================
private volatile static MapManager manager;
private LocationManager lm;
private MapController mapController;
private GeoPoint currentPoint;

private MapManager(Context c){
lm = (LocationManager)c.getSystemService(Context.LOCATION_SERVICE);
}

public static MapManager getInstance(Context c){
if(manager == null){
synchronized (MapManager.class) {
if(manager == null){
manager = new MapManager(c);
}
}
}//if
return manager;
}



//=====================================监听器=============================================================
private final LocationListener locationListener = new LocationListener() {

    public void onLocationChanged(Location loc) { //当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
        // log it when the location changes
        if (loc != null) {
            GeoPoint myPoint = new GeoPoint((int)loc.getLatitude()*1000000, (int)loc.getLongitude()*1000000);
            mapController.setCenter(myPoint);
        }
    }
    public void onProviderDisabled(String provider) {
    // Provider被disable时触发此函数,比如GPS被关闭
    }
    public void onProviderEnabled(String provider) {
    //  Provider被enable时触发此函数,比如GPS被打开
    }
    public void onStatusChanged(String provider, int status, Bundle extras) {
    // Provider的转态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
    }
};

//*********************************对外的接口*******************************************************
public void startAutoUpdate(){
lm.requestLocationUpdates("gps", 0, 1000, locationListener);
}

public void setCurrentLocToCenter(MapController mapController){
this.mapController = mapController;
//得到当前位置信息,设置在地图上
Location  loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
currentPoint = new GeoPoint((int)loc.getLatitude()*1000000, (int)loc.getLongitude()*1000000);
mapController.setCenter(currentPoint);
}

public void addCurrentOverLapToMap(MapView mapView){
//绘制提示信息
MyOverlay mo = new MyOverlay(currentPoint);
mo.onTap(currentPoint, mapView);
mapView.getOverlays().add(mo);
}

//===================================悬浮层定义=============================================================
protected class MyOverlay extends Overlay{
private GeoPoint point;

public MyOverlay(GeoPoint point){
this.point = point;
}

public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);

//转换地图的经纬度到像素   Geopoint ---->  point
Point screenXY = new Point();
mapView.getProjection().toPixels(point, screenXY);

String warning = "I'm here";

//绘制一个方框
Paint p = new Paint();
p.setStyle(Style.FILL);
p.setAntiAlias(true);
//p.setColor(Color.BLUE);
p.setARGB(128, 255, 0, 0);
float warningWidth = p.measureText(warning);
float width = warningWidth + 0.5f;
float high = 25;

RectF roundRect = new RectF(screenXY.x-width/2-2, screenXY.y, screenXY.x+width/2+2, screenXY.y+high);

canvas.drawRoundRect(roundRect, 5, 5, p);

//p.setARGB(255, 51, 51, 255);

//绘制文字“ I'm here  ”
p.setColor(Color.BLUE);
canvas.drawText(warning, screenXY.x-width/2-2, screenXY.y+high+1, p);
p.setColor(Color.GREEN);
canvas.drawCircle(screenXY.x, screenXY.y, 3, p);
}
}
}

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android中通过view方式获取当前Activity的屏幕截... iis7站长之家
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3