I have an image setup inside an absolute panel.I am trying to set it's position via code.But I do not see any applicable method/property to set its position.
Here is my layout.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/marker" android:src开发者_开发百科="@drawable/marker" android:layout_y="106dp" android:layout_x="290dp"></ImageView>
</AbsoluteLayout>
Here is my code to set its position
marker = (ImageView)findViewById(R.id.marker);
marker.//Can't find a method or property
- Don't use
AbsoluteLayout
. It's deprecated. UseFrameLayout
. - With a FrameLayout, you can create a
FrameLayout.LayoutParams
object for your view, and specify the margin on the left and top. - If you want to animate your view, you can use a
TranslateAnimation
.
If you need to add multiple elements, encapsulate them into a layout and put those underneath your FrameLayout.
精彩评论