0
How to add items in Android?
I do not understand how I add things in Android. In this code I am trying to add another string but I can't make it work. I know that android code does not work in Android, but what syntax would be used to add things in Android? https://code.sololearn.com/clY75g67ML18/?ref=app
4 Antworten
+ 5
You set layout_width and layout_height of both textviews to match_parent.
It will fill up all the dimensions of parent view.
All you see is big textview that filled up hole entire screen.
You have to use wrap_content for both height and width of your text view.
I think this is what you really want,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txt_hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:text="Hello world" />
<TextView
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:text="hello" />
</LinearLayout>
+ 5
Also you need to look at this documentation about layout's,
https://developer.android.com/guide/topics/ui/declaring-layout
+ 1
Ah thank you it works now
0
To be clear I want to have two text views but everything I do seems to only support one.