Java Android隐藏和显示组件
我正在制作一个sqlite android应用程序,它列出一些数据,显示图表,通过启动默认浏览器访问网站,而不是使用webview在应用程序中,通过使用表单发送电子邮件。我要几张表格。所以我想的是,我没有使用多个活动和xml布局,而是将它们全部放在一个xml布局中,只需单击按钮即可显示和隐藏组件,就像使用javascript一样 这些是我现在的组件Java Android隐藏和显示组件,java,android,Java,Android,我正在制作一个sqlite android应用程序,它列出一些数据,显示图表,通过启动默认浏览器访问网站,而不是使用webview在应用程序中,通过使用表单发送电子邮件。我要几张表格。所以我想的是,我没有使用多个活动和xml布局,而是将它们全部放在一个xml布局中,只需单击按钮即可显示和隐藏组件,就像使用javascript一样 这些是我现在的组件 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="432dp"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="ENTER COMPANY NAME " />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:ems="10">
<requestFocus />
</EditText>
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
android:entries="@array/country_arrays"
android:prompt="@string/country_prompt"
/>
<Spinner
android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/spinner1"
android:layout_below="@+id/spinner1"
android:entries="@array/limit_arrays"
android:prompt="@string/limit_prompt"
/>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/spinner2"
android:layout_centerHorizontal="true"
android:text="Hide" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:text="Show" />
</RelativeLayout>
</ScrollView>
这看起来很好,但我的xml屏幕上的空间越来越小。如何在底部放置更多组件,并使视图向下滚动,尽管我已经放置了
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
在我的xml布局的顶部。对于菜单组织来说,这是一个好主意吗?我认为这是一个问题,因为相对布局有一个固定的高度。我应该使用wrap_内容吗?是的,你应该……因为固定的高度,这可能是一个问题。但同样,如果我已经在屏幕上有一些组件,Android sdk不允许我放置更多组件,当我放置wrap_内容时,它被限制为布局中所有组件的高度,将新组件置于其他组件之上!?在ScrollView中不能放置多个布局..,因为它只包含一个子视图。。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">