[英]buttons disappearing from a linear layout
I have a complicated linear layout, with some buttons and edittext: 我有一个复杂的线性布局,带有一些按钮和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). 一切看起来都应该在大屏幕(平板电脑)上进行:我有第一行的edittext和两个按钮,在下面的行中有另一个按钮,在下面的行中有scrollview(有表)。 When I switch to normal screen (smartphone), only the first line is appearing, the rest not being visible.
当我切换到普通屏幕(智能手机)时,仅出现第一行,其余部分不可见。 What could the solution be?
解决方案是什么?
在小屏幕设备中,您设置的边距存在问题,请尝试从ParentLayout
删除android:layout_marginBottom="400dp"
并根据它们管理Layout
At the second linear_layout (that have horizontal orientation) all of your views, have match parent width that cause non of them are visible. 在第二个linear_layout(具有水平方向)上,所有视图的父级宽度都匹配,这导致所有视图都不可见。 I think it's what you want:
我认为这就是您想要的:
` `
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/text"
android:hint="@string/hint"
android:layout_width="0dp"
android:layout_weight = "1"
android:layout_height="wrap_content"
android:minWidth="150dp"
android:textSize="10sp"/>
<Button
android:id="@+id/text2"
android:hint="@string/favourites"
android:layout_width="0dp"
androidlayout_weight = "1"
android:layout_height="wrap_content"
android:textSize="10sp"
/>
<Button
android:id="@+id/text3"
android:hint="@string/clean"
android:layout_width="0dp"
android:layout_weight = "1"
android:layout_height="wrap_content"
android:textSize="10sp"
/>
</LinearLayout>
` `
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.