EditText doesn't resize on phone, only on tablet

266 views Asked by At

I have an EditText that fills the width of the screen. On the right is a button that makes a side panel appear. When the side panel appears, the EditText resizesso the panel and EditText are side by side. This works on Tablets but when I test it on the phone the EditText only takes up 1/2 the screen and doesn't resize.

What it looks like with the panel open

What it looks like with panel closed. The EditText should resize

main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainlayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right" >

    <com.mobilewebtoolkit.EditTextLineNumbers
        android:id="@+id/ide"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:ems="10"
        android:gravity="left"
        android:inputType="textMultiLine"
        android:lineSpacingExtra="5dp"
        android:textSize="15sp"
        android:visibility="visible" >

    </com.mobilewebtoolkit.EditTextLineNumbers>

    <WebView
        android:id="@+id/webpreview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:visibility="gone" />

        <Button
            android:id="@+id/show_popup_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="950dp"
            android:layout_toLeftOf="@+id/popup_window"
            android:background="@drawable/download_button" />

        <com.mobilewebtoolkit.TransparentPanel
            android:id="@+id/popup_window"
            android:layout_width="250dp"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="#ffffff"
            android:orientation="vertical"
            android:paddingLeft="10dp"
            android:paddingTop="20dp"
            android:visibility="gone" >

            <ListView
                android:id="@+id/fileList"
                android:layout_width="239dp"
                android:layout_height="370dp"
                android:layout_below="@+id/liveToggle" >

            </ListView>

            <HorizontalScrollView
                android:id="@+id/commonscroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/TextView01"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Common"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="48dp" >

                        <Button
                            android:id="@+id/commonTagsBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="55dp"
                            android:text="&lt;>&lt;/>" />

                        <Button
                            android:id="@+id/commonTabBtn"
                            android:layout_width="96dp"
                            android:layout_height="55dp"
                            android:layout_marginBottom="25dp"
                            android:text="Tab" />

                    </LinearLayout>
                </LinearLayout>
            </HorizontalScrollView>

            <HorizontalScrollView
                android:id="@+id/htmlscroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="false"
                android:layout_below="@id/commonscroll" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="HTML"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <Button
                            android:id="@+id/htmlLinkBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Link" />

                        <Button
                            android:id="@+id/htmlImageBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Image" />

                        <Button
                            android:id="@+id/htmlUlBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Unordered List" />

                        <Button
                            android:id="@+id/htmlOLBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Ordered List" />

                        <Button
                            android:id="@+id/htmlTableBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Table" />

                        <Button
                            android:id="@+id/htmlFormBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Form" />

                        <Button
                            android:id="@+id/htmlInputBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Input" />

                        <Button
                            android:id="@+id/htmlTABtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="TextArea" />
                    </LinearLayout>
                </LinearLayout>
            </HorizontalScrollView>

            <HorizontalScrollView
                android:id="@+id/jqueryscroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/htmlscroll" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="jQuery"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <Button
                            android:id="@+id/jqMobPage"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Page" />

                        <Button
                            android:id="@+id/jqMobHeaderBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Header" />

                        <Button
                            android:id="@+id/jqMobContentBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Content" />

                        <Button
                            android:id="@+id/jqMobFooterBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Footer" />

                        <Button
                            android:id="@+id/jqMobNavBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:text="Navbar" />
                    </LinearLayout>
                </LinearLayout>
            </HorizontalScrollView>

            <HorizontalScrollView
                android:id="@+id/cssscroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/jqueryscroll"
                android:layout_marginBottom="25dp" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="CSS"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <LinearLayout
                        android:layout_width="320dp"
                        android:layout_height="wrap_content" >

                        <Button
                            android:id="@+id/cssOpenTagBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:paddingLeft="25dp"
                            android:paddingRight="25dp"
                            android:text="{" />

                        <Button
                            android:id="@+id/cssCloseTagBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:paddingLeft="25dp"
                            android:paddingRight="25dp"
                            android:text="}" />

                        <Button
                            android:id="@+id/cssColonTagBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:paddingLeft="25dp"
                            android:paddingRight="25dp"
                            android:text=":" />

                        <Button
                            android:id="@+id/cssSemiColonBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:paddingLeft="25dp"
                            android:paddingRight="25dp"
                            android:text=";" />

                        <Button
                            android:id="@+id/cssHyphenBtn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:paddingLeft="25dp"
                            android:paddingRight="25dp"
                            android:text="-" />

                    </LinearLayout>
                </LinearLayout>
            </HorizontalScrollView>

            <Button
                android:id="@+id/prevBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/fileList"
                android:layout_below="@+id/cssscroll"
                android:text="@string/preview" />

            <ToggleButton
                android:id="@+id/liveToggle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/prevBtn"
                android:layout_centerHorizontal="true"
                android:enabled="false"
                android:text="@string/Liveon"
                android:textOff="@string/Liveoff"
                android:textOn="@string/Liveon" />

        </com.mobilewebtoolkit.TransparentPanel>

</RelativeLayout>

The listener in main.java that handles the panel's button

final Button btn = (Button) findViewById(R.id.show_popup_button);
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (key == 0) {
                    key = 1;
                    popup.setVisibility(View.VISIBLE);
                    btn.setBackgroundResource(R.drawable.upload_button);
                } else if (key == 1) {
                    key = 0;
                    popup.setVisibility(View.GONE);
                    //et.setWidth(1024);
                    btn.setBackgroundResource(R.drawable.download_button);
                }
            }
        });

Why isn't my EditText automatically resizing on phones?

EDIT It works correctly on an Android phone sim, but not the Android runtime on the BlackBerry z10

1

There are 1 answers

1
RapsFan1981 On

Got it. The gravity on my main layout was set to left. Just had to change it to fil.