我的活动在屏幕顶部有一个图像。 Image下面的所有内容都需要可滚动。见下图:
我尝试将ScrollView布局放在图片下方,但我继续收到错误说“语句意外结束”,但ScrollView的开头标记是正确的,所以我发疯了!
这是我的XML代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rkmsolutions.restaurantapp.MainActivity">
<ImageView
android:id="@+id/sapori_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@drawable/sapori_logo_cropped"
tools:ignore="ContentDescription" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/sapori_banner">
<ImageView
android:id="@+id/olivesAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/olives512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/oliveAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="start"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/olivesAppetizerTitleTxtView"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/oliveAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/olivesAppetiserImage"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="center_vertical"
android:text="@string/oliveAppetizerDescription" />
<TextView
android:id="@+id/oliveAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/oliveAppetisersBodyDescription"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toRightOf="@+id/oliveAppetisersBodyDescription"
android:gravity="center"
android:text="@string/oliveAppetiserPriceText" />
<ImageView
android:id="@+id/bruschettaAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/olivesAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/bruschetta512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/bruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/bruschettaAppetiserImage"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/bruschettaAppetiserTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/bruschettaAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_below="@+id/bruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserDescription" />
<TextView
android:id="@+id/bruschettaAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/bruschettaAppetisersBodyDescription"
android:layout_toEndOf="@+id/bruschettaAppetisersBodyDescription"
android:layout_toRightOf="@+id/bruschettaAppetisersBodyDescription"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserPriceText"
android:textAlignment="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/vegetarian_bruschetta512x512"
tools:ignore="ContentDescription"
android:id="@+id/veggieBruschettaAppetiserImage"
android:layout_below="@+id/bruschettaAppetiserImage"/>
<TextView
android:id="@+id/veggieBruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/veggieBruschettaAppetiserImage"
android:layout_toEndOf="@+id/veggieBruschettaAppetiserImage"
android:layout_toRightOf="@+id/veggieBruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/veggieBruschettaTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/veggieBruschettaDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"
android:layout_below="@+id/veggieBruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="Toasted bread with grilled vegetarian antipasti" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/veggieBruschettaPrice"
android:gravity="center"
android:textAlignment="center"
android:text="@string/veggieBruschettaPriceString"
android:layout_toRightOf="@id/veggieBruschettaDescription"
android:layout_toEndOf="@+id/veggieBruschettaDescription"
android:layout_alignTop="@+id/veggieBruschettaDescription"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"/>
<ImageView
android:id="@+id/paneAglioImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@+id/veggieBruschettaAppetiserImage"
android:src="@drawable/garlic_bread_pizza512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/paneAglioTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/paneAglioImage"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/paneAglioTitleString"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:id="@+id/paneAglioDescription"
android:gravity="center_vertical"
android:text="@string/paneAglioDescriptionString"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:layout_below="@+id/paneAglioTitle"
android:layout_alignBottom="@+id/paneAglioImage"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:textAlignment="center"
android:layout_alignBottom="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioDescription"
android:layout_toEndOf="@+id/paneAglioDescription"
android:text="@string/paneAglioPriceString"
android:layout_alignTop="@+id/paneAglioDescription"/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
这将是一个简单的解决方案,但我只是不知道还有什么要尝试! 谢谢你!
答案 0 :(得分:2)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rkmsolutions.restaurantapp.MainActivity">
<ImageView
android:id="@+id/sapori_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@drawable/sapori_logo_cropped"
tools:ignore="ContentDescription" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/sapori_banner">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/olivesAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/olives512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/oliveAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="start"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/olivesAppetizerTitleTxtView"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/oliveAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/olivesAppetiserImage"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="center_vertical"
android:text="@string/oliveAppetizerDescription" />
<TextView
android:id="@+id/oliveAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/oliveAppetisersBodyDescription"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toRightOf="@+id/oliveAppetisersBodyDescription"
android:gravity="center"
android:text="@string/oliveAppetiserPriceText" />
<ImageView
android:id="@+id/bruschettaAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/olivesAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/bruschetta512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/bruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/bruschettaAppetiserImage"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/bruschettaAppetiserTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bruschettaAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_below="@+id/bruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserDescription" />
<TextView
android:id="@+id/bruschettaAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/bruschettaAppetisersBodyDescription"
android:layout_toEndOf="@+id/bruschettaAppetisersBodyDescription"
android:layout_toRightOf="@+id/bruschettaAppetisersBodyDescription"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserPriceText"
android:textAlignment="center" />
<ImageView
android:id="@+id/veggieBruschettaAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bruschettaAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/vegetarian_bruschetta512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/veggieBruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/veggieBruschettaAppetiserImage"
android:layout_toEndOf="@+id/veggieBruschettaAppetiserImage"
android:layout_toRightOf="@+id/veggieBruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/veggieBruschettaTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/veggieBruschettaDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"
android:layout_below="@+id/veggieBruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="Toasted bread with grilled vegetarian antipasti" />
<TextView
android:id="@+id/veggieBruschettaPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/veggieBruschettaDescription"
android:layout_toEndOf="@+id/veggieBruschettaDescription"
android:layout_toRightOf="@id/veggieBruschettaDescription"
android:gravity="center"
android:text="@string/veggieBruschettaPriceString"
android:textAlignment="center" />
<ImageView
android:id="@+id/paneAglioImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/veggieBruschettaAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/garlic_bread_pizza512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/paneAglioTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/paneAglioImage"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/paneAglioTitleString"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/paneAglioDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/paneAglioImage"
android:layout_below="@+id/paneAglioTitle"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:gravity="center_vertical"
android:text="@string/paneAglioDescriptionString" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/paneAglioImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/paneAglioDescription"
android:layout_toEndOf="@+id/paneAglioDescription"
android:layout_toRightOf="@+id/paneAglioDescription"
android:gravity="center"
android:text="@string/paneAglioPriceString"
android:textAlignment="center" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
答案 1 :(得分:1)
您应该将ImageView
放在RelativeLayout
alignParentTop
属性上。您应该为ImageView
和TextViews
定义容器布局。
这里的关键点; ScrollView
只能容纳一个孩子。因此,您将在ScrollView
内添加容器布局,并定义layout_below
属性,使其位于横幅下方
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rkmsolutions.restaurantapp.MainActivity">
<ImageView
android:id="@+id/sapori_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@drawable/sapori_logo_cropped"
tools:ignore="ContentDescription" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/sapori_banner">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/olivesAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/olives512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/oliveAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="start"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/olivesAppetizerTitleTxtView"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/oliveAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/olivesAppetiserImage"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toEndOf="@+id/olivesAppetiserImage"
android:layout_toRightOf="@+id/olivesAppetiserImage"
android:gravity="center_vertical"
android:text="@string/oliveAppetizerDescription" />
<TextView
android:id="@+id/oliveAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/oliveAppetisersBodyDescription"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/oliveAppetiserTitle"
android:layout_toRightOf="@+id/oliveAppetisersBodyDescription"
android:gravity="center"
android:text="@string/oliveAppetiserPriceText" />
<ImageView
android:id="@+id/bruschettaAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/olivesAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/bruschetta512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/bruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/bruschettaAppetiserImage"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/bruschettaAppetiserTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bruschettaAppetisersBodyDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_below="@+id/bruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserDescription" />
<TextView
android:id="@+id/bruschettaAppetiserPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/bruschettaAppetiserImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/bruschettaAppetisersBodyDescription"
android:layout_toEndOf="@+id/bruschettaAppetisersBodyDescription"
android:layout_toRightOf="@+id/bruschettaAppetisersBodyDescription"
android:gravity="center_vertical"
android:text="@string/bruschettaAppetiserPriceText"
android:textAlignment="center" />
<ImageView
android:id="@+id/veggieBruschettaAppetiserImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bruschettaAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/vegetarian_bruschetta512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/veggieBruschettaAppetiserTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/veggieBruschettaAppetiserImage"
android:layout_toEndOf="@+id/veggieBruschettaAppetiserImage"
android:layout_toRightOf="@+id/veggieBruschettaAppetiserImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/veggieBruschettaTitle"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/veggieBruschettaDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"
android:layout_below="@+id/veggieBruschettaAppetiserTitle"
android:layout_toEndOf="@+id/bruschettaAppetiserImage"
android:layout_toRightOf="@+id/bruschettaAppetiserImage"
android:gravity="center_vertical"
android:text="Toasted bread with grilled vegetarian antipasti" />
<TextView
android:id="@+id/veggieBruschettaPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/veggieBruschettaAppetiserImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/veggieBruschettaDescription"
android:layout_toEndOf="@+id/veggieBruschettaDescription"
android:layout_toRightOf="@id/veggieBruschettaDescription"
android:gravity="center"
android:text="@string/veggieBruschettaPriceString"
android:textAlignment="center" />
<ImageView
android:id="@+id/paneAglioImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/veggieBruschettaAppetiserImage"
android:scaleType="centerCrop"
android:src="@drawable/garlic_bread_pizza512x512"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/paneAglioTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/paneAglioImage"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/paneAglioTitleString"
android:textColor="#b71c1c"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/paneAglioDescription"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/paneAglioImage"
android:layout_below="@+id/paneAglioTitle"
android:layout_toEndOf="@+id/paneAglioImage"
android:layout_toRightOf="@+id/paneAglioImage"
android:gravity="center_vertical"
android:text="@string/paneAglioDescriptionString" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/paneAglioImage"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/paneAglioDescription"
android:layout_toEndOf="@+id/paneAglioDescription"
android:layout_toRightOf="@+id/paneAglioDescription"
android:gravity="center"
android:text="@string/paneAglioPriceString"
android:textAlignment="center" />
</RelativeLayout>
答案 2 :(得分:0)
尝试这种方式它将起作用
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:background="#689F38"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/header_msg"
android:textColor="#FFFFFF"
android:textSize="25sp"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:background="#689F38"
android:gravity="center"
android:layout_gravity="center">
<TextView
android:id="@+id/footer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/footer_msg"
android:textColor="#FFFFFF"
android:gravity="center"
android:textSize="25sp"/>
</RelativeLayout>
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer"
android:layout_below="@+id/header"
android:fillViewport="true">
<LinearLayout
android:id="@+id/myLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:fillViewport="true">
<TextView
android:id="@+id/bodytext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/body_msg"
android:textColor="#F44336"
android:gravity="center"
android:textSize="25sp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
有关详情this