Vertical linear layout doesn't show up, but horizontal does in java xml file -
i've started java programming in school, , first assignment recreate app working on using xml layout instead of programmatically creating elements. have 2 separate linear layouts want appear, 1 horizontal , 1 vertical. of horizontal layouts appear fine, whenever try add vertical one, adds not show up. in emulator, can tell it's being added because horizontal lls pushed around.
here's example of code:
<?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" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <button android:id="@+id/randombutton" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight=".5" android:text="derp" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="hiiiii" /> <button android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="badoop" /> </linearlayout> </linearlayout> any suggestions? thanks,
david
i copied code eclipse layout view.
- you left off closing linearlayout element. missed in copy paste, if not, add it.
- the "0dip" width gave me errors. when switched "wrap_content" worked fine.
- the textview isn't showing because blackground , text both black.
here's textview , button:
<textview android:layout_width="wrap_content" android:textcolor="@color/white" android:layout_height="wrap_content" android:layout_weight="1" android:text="hiiiii" /> <button android:layout_width="wrap_content" android:textcolor="@color/black" android:layout_height="wrap_content" android:layout_weight="1" android:text="badoop" />
Comments
Post a Comment