Reputation: 545
I am new to Android, so please dont be very harsh,
I am writing an application that simply displays a triangle on the android emulator screen, I have written a Triangle class and tested the picture in eclipse console! and it displayed perfectly however when I launch it in the emulator my triangle is off!
I have tried using various layouts, but nothing seems to solve the problem. Please help
layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
Activity class
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = (TextView) this.findViewById(R.id.text1);
Triangle triangle = null;
try {
triangle = new Triangle (20);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
text.setText(triangle.toString());
// text.setText("HERE SHOULD BE A TRIANGLE");
}
Upvotes: 1
Views: 55
Reputation: 545
The solutions is that there can be monospaced font and proportional font. In my case it had to be changed to monospased. Solution in code below
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="monospace"
android:text="@string/hello_world"
/>
Upvotes: 2