helius83 helius83 - 5 months ago 16
Android Question

buttons disappearing from a linear layout

I have a complicated linear layout, with some buttons and edittext:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top|center_horizontal"
android:orientation="vertical"
android:weightSum="1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="400dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="0dp"
android:text="@string/stop"
android:textSize="18dp"
android:textStyle="bold" />



<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/text"
android:hint="@string/hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/choose"
android:layout_alignParentLeft="true"
android:minWidth="150dp"
android:textSize="10sp"/>
<Button
android:id="@+id/text2"
android:hint="@string/favourites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/choose"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/text"
android:textSize="10sp"
/>
<Button
android:id="@+id/text3"
android:hint="@string/clean"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/choose"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/text"
android:textSize="10sp"
/>
</LinearLayout>

<Button
android:id="@+id/button"
android:text="@string/request"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text2"
android:onClick="lookUp"
android:textSize="12sp"
/>


<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#3d455b"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button">

<HorizontalScrollView
android:id="@+id/hscrll1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_gravity="left"
android:layout_height="fill_parent"
android:orientation="vertical" >


<TableLayout
android:id="@+id/table_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="false"
android:stretchColumns="2">
</TableLayout>
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>

</LinearLayout>


Everything looks at it should on a large screen (tablet): I have the first line with the edittext and two buttons, on the line below I have the other button, and below it I have the scrollview (with the table).
When I switch to normal screen (smartphone), only the first line is appearing, the rest not being visible.
What could the solution be?

Answer

In Small Screen device there are problem with margin you set, try to remove android:layout_marginBottom="400dp" from your ParentLayout and manage your Layout according them

Comments