android - linearlayout weight not working with vertical orientation -
i trying divide whole screen 3 buttons such each button occupies full breadth of screen , length of screen divided equally between these buttons. graphical layout of xml file shown @ http://i.stack.imgur.com/zsqvg.png
this xml code below working when use android studio. when use eclipse not work. displays content of fragment_main.xml.(hello world!) may reason due happening? found not use weights when linearlayout in vertical orientation simplest cases 1 shown in example.
the xml code layout is-
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightsum="3" > <button android:id="@+id/btnbutton1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="button 1" /> <button android:id="@+id/btnbutton2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="button 2" /> <button android:id="@+id/btnbutton3" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="button 3" /> </linearlayout>
but when run code in eclipse empty screen. if remove android:layout_weight="1" every in xml file , change android:layout_height android:layout_height="40dp" (and removing android:weightsum="3" too) runs shown in graphical layout.
the code have posted , 1 provided haresh chhelana both correct. had not tested xml file after running app. looking @ preview eclipse shows real time edit xml file. seems there bug in eclipse due error occurs. xml file works fine when use in our application.
Comments
Post a Comment