android 螢幕適配原則

螢幕大小1、不同的layout      Android手機螢幕大小不一,有480x320,640x360,800x480.怎樣才能讓App自動適應不同的螢幕呢? 其實很簡單,只需要在res目錄下建立不同的layout檔案夾,比如:layout-640x360,layout-800x480,所有的layout檔案在編譯之後都會寫入R.java裡,而系統會根據螢幕的大小自己選擇合適的layout進行使用。2、hdpi、mdpi、ldpi 

SurfaceView繪圖機制

雖然前面都使用的View來進行繪圖,但View繪圖機制存在兩個缺陷:1、缺乏雙緩衝機制2、更新映像時,必須更新View上的整張圖片,效率低。所以在遊戲繪製中推薦使用SurfaceView。它可以只對指定地區進行更新,可以提高效率。下面用一個簡單樣本來示範SurfaceView的使用:Activity: package com.home.activity; import android.app.Activity; import android.graphics.Bitmap;

android usb host 讀寫USB裝置

關於如何監聽裝置插拔以及擷取裝置許可權我就不說了,大家可以在網上搜一下有很多這方面的文章,我這裡就說一下如何讀寫資料。  UsbInterface usbInterface = usbDevice.getInterface(0); //USBEndpoint為讀寫資料所需的節點 UsbEndpoint inEndpoint = usbInterface.getEndpoint(0); //讀資料節點 UsbEndpoint outEndpoint =

自訂進度條

public class CircleView extends View {      private int maxProgress = 100;     private int progress = 30;     private int progressStrokeWidth = 4;     //

Android音效SoundPool問題:soundpool 1 not retry

Android音效SoundPool問題:soundpool 1 not retry 今天開發中要用到SoundPool,遇到soundpool 1 not retry無法播放聲音,MediaPlay可以 後來經過一番研究,發現:出現soundpool 1 not retry問題的代碼,無法播放聲音mgr = (AudioManager)

android ListView用法

print?<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

Android-- SharedPreferences資料存放區XML檔案的方法

SharedPreferences是Android平台上一個輕量級的儲存類,主要是儲存一些常用的配置比如視窗狀態,一般在Activity中 重載視窗狀態onSaveInstanceState儲存一般使用SharedPreferences完成,它提供了Android平台常規的Long長 整形、Int整形、String字串型的儲存。  在Fragment中的使用方法  @Override  public void onCreate(Bundle

Android--使用Http向伺服器發送請求並取得返回結果,下載圖片

由於最近在做的一個遊戲項目有一個熱門排行榜, 熱門排行榜是一個列表,介面大致如下:   排名     人物名稱     頭像圖片     分數 排名     人物名稱     頭像圖片     分數 排名     人物名稱     頭像圖片    

android PopuWidow 使用總結

1.requestFocus() 擷取焦點模式2.PopuWidow 設定其動畫寫xml 補禎動畫,在style 樣式xml 檔案中寫<stye name="動畫名稱" ><item name="@android:windowEnterAnimation" >開啟動畫</item><item name="@android:windowExitAnimation"

Monkey測試簡介

在android手機上做自動化測試,monkey比cts,Android UnitTest 好用多了,他其實是繼承與adb

android學習-動畫(基本的四種動畫)

先看段關於android中動畫設定檔的虛擬碼:<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> &

android 開發中判斷網路是否串連的代碼

在android的開發中,尤其是與訪問網路有關的開發,都要判斷一下手機是否串連上了網路,下面是一個判斷是否串連網路的嗲嗎片段:package cn.com.karl.util;import com.kubu.main.R;import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import

Android中使用ListView實現自適應表格

GridView比ListView更容易實現自適應的表格,但是GridView每個格單元的大小固定,而ListView實現的表格可以自訂每個格單元的大小,但因此實現自適應表格也會複雜些(格單元大小不一)。另外,GridView實現的表格可以定位在具體某個格單元,而ListView實現的表格則只能定位在表格行。因此還是那句老話:根據具體的使用環境而選擇GridView 或者

Android開源項目SlideMenu學習(一)

SlideMenu項目依賴ActionBarSherlock這個開源項目,所以研究它需要下載兩個開源項目。使用Git分別為:SlideMenu:https://github.com/jfeinstein10/SlidingMenu.gitActionBarSherlock: https://github.com/JakeWharton/ActionBarSherlock.git 這次主要講解在學習該項目執行個體過程中經常遇到的錯誤,下次在講解具體案例。1

android 數組資料繫結到listview

package com.zxl;import android.app.ListActivity;import android.os.Bundle;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ListView;import android.widget.Toast;public class MainActivity extends ListActivity { /**

android 程式防止被360或者系統給kill掉

關於如果和防止android 程式防止被360kill掉之後重啟的問題,肯定大家也搜尋了好多方法,都不好使,對不對,什麼增高許可權了,什麼進程優先順序了,這些東西都不是我們可控的,所以有沒有一些非常保險的方法,讓程式被kill掉之後自動重啟呢。  大家發現沒有,當我們使用360進行程式清理的時候,有些應用自己快速的啟動起來了,他們是怎麼實現的呢?其實我們沒有見過他們的源碼,也不好說是怎麼實現的。 

android-文字的處理-隨心

一、計算文字的大小 String timeStr = "00:00"; int textWidth = (int)Layout.getDesiredWidth(timeStr, 0, timeStr.length(), tp);二、文字加粗 TextPaint tp = text.getPaint(); tp.setFakeBoldText(true);三、文字加底線 String str = "底線";

Android判斷當前應用是否在前台運行

package cn.testforeground;import java.util.List;import android.os.Bundle;import android.app.Activity;import android.app.ActivityManager;import android.app.ActivityManager.RunningTaskInfo;import android.content.ComponentName;import

Android_UI_點擊按鈕切換背景效果實現

實現按鈕按下和釋放,按鈕背景圖片相應轉場效果的方法這裡介紹兩種,一種是在代碼裡實現,另一種是在xml檔案裡實現一、在xml檔案裡首先現在layout的一個xml檔案下定義Button如下所示: [html]<Button      android:id="@+id/btn_user_selected"    

Android仿Iphone通知角標的實現(二)

package cc.testtipmessage1;import android.os.Bundle;import android.widget.ImageView;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Bitmap.Config;import android.graphics.BitmapFactory;

總頁數: 2771 1 .... 1098 1099 1100 1101 1102 .... 2771 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.