綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] 想做一航向指示器

[複製連結] 查看: 845|回覆: 8|好評: 0
跳轉到指定樓層
樓主
Tony10153117 | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2013-5-13 23:10

馬上加入Android 台灣中文網,立即免費下載應用遊戲。

您需要 登錄 才可以下載或查看,沒有帳號?註冊

x
想要做一個如圖中間下面的航向指示器
「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

沙發
whl | 收聽TA | 只看該作者
發表於 2013-5-13 23:18
sensor 或 GPS 方面下手,這樣才取得到北方。

評分

參與人數 1幫助 +1 收起 理由
ploglin + 1

查看全部評分

用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

板凳
 樓主| Tony10153117 | 收聽TA | 只看該作者
發表於 2013-5-14 20:40
本帖最後由 Tony10153117 於 2013-5-14 23:12 編輯


我有找到一個航向指示器的APP程式;Google了一下是說把這個應用程式的.apk檔
副檔名改成.ZIP,然後解壓縮就可以用eclipse開啟;
我載了一個.apk檔,照上面的方法試了一下,但eclipse沒辦法匯入解壓縮出來的東西
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

地板
whl | 收聽TA | 只看該作者
發表於 2013-5-15 16:38
Tony10153117 發表於 2013-5-14 20:40
我有找到一個航向指示器的APP程式;Google了一下是說把這個應用程式的.apk檔
副檔名改成.ZIP,然後解壓縮 ...

這種說法是哪個人亂講的。我認為您應該沒寫過 Android APP,不然你不可能相信這種說法。
我建議你先買書學寫 APP。
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

5
 樓主| Tony10153117 | 收聽TA | 只看該作者
發表於 2013-5-16 09:51
whl 發表於 2013-5-15 16:38
這種說法是哪個人亂講的。我認為您應該沒寫過 Android APP,不然你不可能相信這種說法。
我建議你先買書 ...

有買書自學,書上是做一個BMI計算器;
那假如我有一資料值是0~360度,用這個資料當作航向
(例:0、360度時航向就是北,90度時航向是東,180度時航向是南,270度時航向是西)
所以我不用用到Sensor,因為航向資料輸入是0~360度,依照傳入的0~360度轉動羅盤
我應該從哪裡學?
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

6
whl | 收聽TA | 只看該作者
發表於 2013-5-16 20:04
Tony10153117 發表於 2013-5-16 09:51
有買書自學,書上是做一個BMI計算器;
那假如我有一資料值是0~360度,用這個資料當作航向
(例:0、360度時 ...

這對初學者有些難,最主要是圖片的旋轉問題,網路有很多範例。

評分

參與人數 1幫助 +1 收起 理由
Tony10153117 + 1

查看全部評分

用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

7
lung6660 | 收聽TA | 只看該作者
發表於 2013-5-17 09:52
土法煉鋼
準備0~359度的圖,輸入幾度就切換相對應的圖
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

8
 樓主| Tony10153117 | 收聽TA | 只看該作者
發表於 2013-5-17 15:18
謝謝各位大大的提點 我會試試看
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

9
 樓主| Tony10153117 | 收聽TA | 只看該作者
發表於 2013-5-17 18:44
找到一個圖片旋轉的範例,範例是左右旋轉90度,但是當我把旋轉角度改成其他角度時圖片會越轉越小
在ImageView中加入android:scaleType,還是會越轉越小,有什麼解決辦法?

程式碼
.java
  1. package com.example.imagerota;

  2. import android.app.Activity;
  3. import android.graphics.Bitmap;
  4. import android.graphics.Matrix;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.ImageView;
  9. import android.view.Menu;


  10. public class MainActivity extends Activity {

  11.         @Override
  12.         protected void onCreate(Bundle savedInstanceState) {
  13.                 super.onCreate(savedInstanceState);
  14.                 setContentView(R.layout.activity_main);
  15.                
  16.                 Button button_left = (Button)findViewById(R.id.button1);
  17.                 View.OnClickListener listener_left = new View.OnClickListener() {
  18.                        
  19.                         @Override
  20.                         public void onClick(View arg0) {
  21.                                 // TODO Auto-generated method stub
  22.                                 //取得圖片
  23.                                 ImageView imageView_left = (ImageView) findViewById(R.id.imageView1);
  24.                          //imageView_left.setDrawingCacheEnabled(true);
  25.                          //建立圖片的緩存,圖片的緩存本身就是一個Bitmap
  26.                          imageView_left.buildDrawingCache();
  27.                          //取得緩存圖片的Bitmap檔
  28.                          Bitmap bmp=imageView_left.getDrawingCache();
  29.                          //定義一個矩陣圖
  30.                          Matrix m=new Matrix();
  31.                          //取得圖片的寬度
  32.                                 int width=bmp.getWidth();
  33.                                 //取得圖片的長度
  34.                                 int height=bmp.getHeight();
  35.                                 //逆時針旋轉90度
  36.                                 m.setRotate(-89);
  37.                               //產生新的旋轉後Bitmap檔
  38.                                 Bitmap b=Bitmap.createBitmap(bmp, 0, 0, width, height, m, true);
  39.                                  
  40.                                 //顯示圖片
  41.                                 imageView_left.setImageBitmap(b);
  42.                         }
  43.                 };
  44.                 button_left.setOnClickListener(listener_left);
  45.                
  46.                 //圖片右璇90
  47.                 Button button_right = (Button)findViewById(R.id.button2);
  48.                 View.OnClickListener listener_right = new View.OnClickListener() {
  49.                        
  50.                         @Override
  51.                         public void onClick(View v) {
  52.                                 // TODO Auto-generated method stub
  53.                                 //取得圖片
  54.                          ImageView imageView_right = (ImageView) findViewById(R.id.imageView1);
  55.                          //imageView_right.setDrawingCacheEnabled(true);
  56.                          //建立圖片的緩存,圖片的緩存本身就是一個Bitmap
  57.                          imageView_right.buildDrawingCache();
  58.                          //取得緩存圖片的Bitmap檔
  59.                          Bitmap bmp=imageView_right.getDrawingCache();
  60.                          //定義一個矩陣圖
  61.                          Matrix m=new Matrix();
  62.                          //取得圖片的寬度
  63.                                 int width=bmp.getWidth();
  64.                                 //取得圖片的長度
  65.                                 int height=bmp.getHeight();
  66.                                 //順時針旋轉90度
  67.                                 m.postRotate(89);
  68.                                 //產生新的旋轉後Bitmap檔
  69.                                 Bitmap b=Bitmap.createBitmap(bmp, 0, 0, width, height, m, true);
  70.                                  
  71.                                 //顯示圖片
  72.                                 imageView_right.setImageBitmap(b);
  73.                              
  74.                         }
  75.                 };
  76.                 button_right.setOnClickListener(listener_right);
  77.         }
  78.        
  79.        

  80.         @Override
  81.         public boolean onCreateOptionsMenu(Menu menu) {
  82.                 // Inflate the menu; this adds items to the action bar if it is present.
  83.                 getMenuInflater().inflate(R.menu.main, menu);
  84.                 return true;
  85.         }
  86.        
  87.        

  88. }
複製代碼
.xml
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.     xmlns:tools="http://schemas.android.com/tools"
  3.     android:layout_width="match_parent"
  4.     android:layout_height="match_parent"
  5.     android:paddingBottom="@dimen/activity_vertical_margin"
  6.     android:paddingLeft="@dimen/activity_horizontal_margin"
  7.     android:paddingRight="@dimen/activity_horizontal_margin"
  8.     android:paddingTop="@dimen/activity_vertical_margin"
  9.     tools:context=".MainActivity" >

  10.     <ImageView
  11.         android:id="@+id/imageView1"
  12.         android:layout_width="200dp"
  13.         android:layout_height="200dp"
  14.         android:scaleType="fitCenter"
  15.         android:layout_alignParentTop="true"
  16.         android:layout_centerHorizontal="true"
  17.         android:contentDescription="@string/hi"
  18.         android:src="@drawable/hi" />

  19.     <RelativeLayout
  20.         android:id="@+id/relativeLayout1"
  21.         android:layout_width="match_parent"
  22.         android:layout_height="wrap_content" >
  23.     </RelativeLayout>

  24.     <Button
  25.         android:id="@+id/button1"
  26.         android:layout_width="wrap_content"
  27.         android:layout_height="wrap_content"
  28.         android:layout_alignLeft="@+id/imageView1"
  29.         android:layout_below="@+id/imageView1"
  30.         android:layout_marginTop="35dp"
  31.         android:text="@string/left" />

  32.     <Button
  33.         android:id="@+id/button2"
  34.         android:layout_width="wrap_content"
  35.         android:layout_height="wrap_content"
  36.         android:layout_alignBaseline="@+id/button1"
  37.         android:layout_alignBottom="@+id/button1"
  38.         android:layout_alignRight="@+id/relativeLayout1"
  39.         android:layout_marginRight="28dp"
  40.         android:text="@string/right" />

  41. </RelativeLayout>
複製代碼
ImageRota.rar (1.57 MB, 下載次數: 0)
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則