我正在创建一个室内导航应用。我使用wifi的RSSI值进行导航。问题是:当RSSI的值发生变化时,如何用红点移动图像视图?
到目前为止我的工作:
ImageView iv1; //map image
ImageView iv2; //red spot
TextView tv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
this.registerReceiver(this.myRssiChangeReceiver,
new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
iv1=(ImageView)findViewById(R.id.imageView1);
iv2=(ImageView)findViewById(R.id.imageView2);
tv1=(TextView)findViewById(R.id.textView1);
}
private BroadcastReceiver myRssiChangeReceiver
= new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
int newRssi = arg1.getIntExtra(WifiManager.EXTRA_NEW_RSSI, 0);
//result.setText(String.valueOf(newRssi));
tv1.setText(String.valueOf(newRssi));
}};
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.smshah.indoormap.MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/uit_floor_plan" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/loc_ptr" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
答案 0 :(得分:1)
尝试查看this等动画的示例。我认为如果您可以将其与位置更改事件联系起来并更新从 - 到坐标,那么LinearInterpolator就是您的选择。
编辑:查看此TranslateAnimation示例。这可能对你更有帮助。