android圖片點擊全屏
1. 求解 android 圖片點擊一下就放大到全屏,再點一下就回到原界面,這個android源碼誰有呢
package com.pic;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.ImageView;
public class TestanroidpicActivity extends Activity {
/** Called when the activity is first created. */
Bitmap bp=null;
ImageView imageview;
float scaleWidth;
float scaleHeight;
int h;
boolean num=false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Display display=getWindowManager().getDefaultDisplay();
imageview=(ImageView)findViewById(R.id.imageview);
bp=BitmapFactory.decodeResource(getResources(),R.drawable.icon);
int width=bp.getWidth();
int height=bp.getHeight();
int w=display.getWidth();
int h=display.getHeight();
scaleWidth=((float)w)/width;
scaleHeight=((float)h)/height;
imageview.setImageBitmap(bp);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
if(num==true) {
Matrix matrix=new Matrix();
matrix.postScale(scaleWidth,scaleHeight);
Bitmap newBitmap=Bitmap.createBitmap(bp, 0, 0, bp.getWidth(), bp.getHeight(), matrix, true);
imageview.setImageBitmap(newBitmap);
num=false;
}
else{
Matrix matrix=new Matrix();
matrix.postScale(1.0f,1.0f);
Bitmap newBitmap=Bitmap.createBitmap(bp, 0, 0, bp.getWidth(), bp.getHeight(), matrix, true);
imageview.setImageBitmap(newBitmap);
num=true;
}
break;
}
return super.onTouchEvent(event);
}
}
2. 在Android 開發中怎麼全屏顯示
全屏顯示有兩種方法
1:
在onCreate方法裡面加上這句代碼 requestWindowFeature(Window.FEATURE_NO_TITLE);
2 :
//顯示全屏
private void setFullScreen()
{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
//[代碼] 退出全屏函數:
private void quitFullScreen()
{
final WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
3. Android應用如何全屏顯示
要設置Android應用全屏顯示有兩種方式,第一種是在AndroidManifest.xml文件中進行配置,另一種方式是在Activity中進行設置。此處僅描述第二種方式。 設置全屏顯示有兩步工作,首先要取消顯示標題欄,然後在全屏顯示。代碼如下:1@Override2publicvoidonCreate(Bundle savedInstanceState) {3super .onCreate(savedInstanceState);4//使屏幕不顯示標題欄(必須要在setContentView方法執行前執行)5this .requestWindowFeature(Window.FEATURE_NO_TITLE);6//隱藏狀態欄,使內容全屏顯示(必須要在setContentView方法執行前執行)7this .getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,8WindowManager.LayoutParams.FLAG_FULLSCREEN);9setContentView(R.layout.splash);10}強調,設置全屏顯示時,這兩行核心代碼一定要在設置視圖之前執行,即一定要位於setContentView()方法之前。
4. android webview怎樣點擊按鈕全屏播放
重寫以下兩個方法:
1.WebChromeClient.onShowCustomView(android.view.View,android.webkit.WebChromeClient.CustomViewCallback) ;
2.WebChromeClient.onHideCustomView()
然後寫你的邏輯就可以了