I am new to Android development and am currently enjoying it a lot.
I have been building a UI by using the XML file and found it quite easy to build a static UI.
Now, I need to build a UI where one of the TextView positions changes during runtime.
Can this be done using XML only?
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_height="wrap_content"
android:text="0%"
android:layout_width="wrap_content"
android:id="@+id/percent"
android:textSize="15sp"
android:layout_x="41dip"
android:layout_y="295dip">
</TextView>
</AbsoluteLayout>
Now I can position the TextView anywhere by changing the value of layout_x and layout_y. But how to do this at runtime?
I have tried this:
TextView text;
text=(TextView)findViewById(R.id.percent);
Doing text.setText("This can be done"); would easily change the text during run time, but how can I change the postion from code?
If trying out this by using absolute layout, take a look at the following code.
main.xml
CustomPosition.java