Android layout 我的布局中的微调器与文本视图重叠
嘿,伙计们/女孩们,我正在为一个班级项目创建一个食物追踪应用程序。其中,用户添加了一个微调器,该微调器包含一系列项目“食物” 问题:当用户在早餐部分添加6种食物时,它会覆盖下一部分,即午餐。我该如何解决这个问题?我尝试在listview中执行此操作,但遇到了问题 content_main.xmlAndroid layout 我的布局中的微调器与文本视图重叠,android-layout,android-studio,android-spinner,overlap,Android Layout,Android Studio,Android Spinner,Overlap,嘿,伙计们/女孩们,我正在为一个班级项目创建一个食物追踪应用程序。其中,用户添加了一个微调器,该微调器包含一系列项目“食物” 问题:当用户在早餐部分添加6种食物时,它会覆盖下一部分,即午餐。我该如何解决这个问题?我尝试在listview中执行此操作,但遇到了问题 content_main.xml <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xm
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="49dp"
android:text="@string/breakfast"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="127dp"
android:text="Lunch"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView3"
android:layout_marginTop="130dp"
android:paddingBottom="130dp"
android:text="@string/dinner"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignRight="@+id/LLL"
android:layout_alignEnd="@+id/LLL"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:id="@+id/BLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:layout_below="@+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/bkSpinner"
android:layout_weight="0.21"
android:entries="@array/allFoodItems" />
</LinearLayout>
<LinearLayout
android:id="@+id/LLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/addNewDItem"
android:layout_below="@+id/textView3"
android:orientation="vertical"
android:layout_centerHorizontal="true">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/LSpinner"
android:layout_weight="0.21"
android:entries="@array/allFoodItems"/>
</LinearLayout>
<Button
android:id="@+id/addNewLItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView3"
android:text="@string/LButton" />
<Button
android:id="@+id/addNewDItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView4"
android:text="@string/DButton" />
<LinearLayout
android:id="@+id/DLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/textView4"
android:layout_alignEnd="@+id/LLL"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/LLL"
android:orientation="vertical"
android:layout_below="@+id/addNewDItem">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/dnSpinner"
android:entries="@array/allFoodItems" />
</LinearLayout>
<TextView
android:id="@+id/calories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/total"
android:layout_alignEnd="@+id/addNewDItem"
android:layout_alignRight="@+id/addNewDItem"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ff0000"
android:textSize="12dp"/>
<Button
android:id="@+id/total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView4"
android:text="@string/totalCal" />
<Button
android:id="@+id/addNewBItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BButton"
android:layout_column="13"
android:layout_alignTop="@+id/BLL"
android:layout_alignLeft="@+id/addNewDItem"
android:layout_alignStart="@+id/addNewDItem" />
</RelativeLayout>
使用
LinearLayout
设计xml“逐行”:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BrekFast"
android:id="@+id/textView"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/bkSpinner"
android:layout_weight="0.21"
... />
<Button
android:text="Add Breakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BrekFast"
android:id="@+id/textView2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/bkSpinner2"
android:layout_weight="0.21"
... />
<Button
android:text="Add Breakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BrekFast"
android:id="@+id/textView3"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:layout_width="240dp"
android:layout_height="37dp"
android:id="@+id/bkSpinner3"
android:layout_weight="0.21"
... />
<Button
android:text="Add Breakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calories Total"/>
</LinearLayout>
</ScrollView>