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

8th Nov 2020, 4:24 AM
Cam UOR
Cam UOR - avatar
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>
8th Nov 2020, 1:37 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 5
Also you need to look at this documentation about layout's, https://developer.android.com/guide/topics/ui/declaring-layout
8th Nov 2020, 1:38 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 1
Ah thank you it works now
8th Nov 2020, 10:13 PM
Cam UOR
Cam UOR - avatar
0
To be clear I want to have two text views but everything I do seems to only support one.
8th Nov 2020, 4:57 AM
Cam UOR
Cam UOR - avatar