Reputation: 31
In my Android project ,I was simply trying to add a normal Button
and a ToggleButton
so that they would stay horizontally side by side.So,I ensured horizontal orientation and used weightsum and layout_weight
. But I get the exception in graphical layout:
Exception raised during rendering: -1
Exception details are logged in Window > Show View > Error Log and in the graphical layout only the button can be seen. Any help would be highly appreciated.
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="100"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_weight="20"
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
<ToggleButton
android:layout_weight="80"
android:id="@+id/toggleButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="ToggleButton" /></LinearLayout>
Upvotes: 0
Views: 148
Reputation: 1430
I tried your layout and I don't get any exception. Tried to improve it and finally came with this:
<?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="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:text="Button" />
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="ToggleButton" />
Could you try it and check if it still crashes?
Upvotes: 0
Reputation: 126455
Since you have this exception:
Exception raised during rendering: -1
Go to your graphical layout and locate the drop down of the API levels, probably you are using the last one 21, and you don´t have it installed, change to other lever according to your app.
Upvotes: 1