Here’s my layout, I’m getting this message for the 2 buttons in the bottom, even though I have set the weight only for one other widget in the layout, which is not the parent of the buttons (the messageText widget). What am I doing wrong? Thanks.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/status_label"
android:textStyle="bold"
android:textSize="20dip"
android:textColor="#FEFF80"/>
<TextView
android:id="@+id/statusText"
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unsent"
android:textSize="20dip"
android:textColor="#FEFF80"/>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_marginTop="10dip"
android:layout_height="1dip"
android:background="#FEFF80"/>
<TextView
android:layout_marginTop="10dip"
android:layout_marginLeft="11dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/message_number_caption"
android:textSize="15dip"/>
<EditText
android:id="@+id/messageNumber"
android:inputType="phone"
android:layout_marginTop="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="30dip"
android:layout_marginLeft="11dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/message_text_caption"
android:textSize="15dip"/>
<EditText android:inputType="text"
android:id="@+id/messageText"
android:layout_marginTop="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1.0"
android:layout_width="fill_parent"
android:layout_height="0dip"/>
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/sendButton"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/send_button_label"
android:textSize="15dip"/>
<Button
android:id="@+id/resetButton"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/reset_button_label"
android:textSize="15dip"/>
</LinearLayout>
</LinearLayout>
You’ve specified an edit text (@+id/messageText) with a weight of 1 – did you mean to do that because the other widgets in that linear layout don’t have a weight?
Then below that you have a linearlayout with two buttons that use weight legitimately.
N.B. it’s quite a simple layout so you’re probably fine. If you had deeper hierarchy with more layouts and widgets then you would be more likely to see a slow down.