加入线性和相对布局滚动型在一个XML文件 [英] Add a ScrollView in Linear and Relative Layout in one XML file

查看:204
本文介绍了加入线性和相对布局滚动型在一个XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让相对布局为滚动型的内容,作为其在屏幕上不恰当。同时包含我的XML文件,线性和线性的地方充当父相对布局和相对的子布局。

I am trying to make the contents of Relative Layout as Scrollview as its not fitting in the screen. My XML file that consists of both, Linear and Relative Layout where Linear is acting as Parent and Relative as child layout.

虽然我已经浏览,大多数关于这个话题的问题,但我能找到的是如何在直线或相对布局插入滚动型分别,但不是在这两种布局在一个文件中。

Although I have browsed, most of the questions regarding this topic, but all i could find is how to insert Scrollview in Linear or Relative Layout respectively but not when both layouts are in one file.

我的XML文件

<?xml version="1.0" encoding="UTF-8"?>

<!-- 
   Being of Linear Layout
 -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >


    <TextView
        android:id="@+id/week1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/week1"
        android:textColor="#FFFFFF"
        android:textSize="25sp"
        android:paddingTop="50dp"
        android:background="#00141c" />
<!--
Begin Relative Layout
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/treadmillimage"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/treadmill" />

    <EditText
        android:id="@+id/durOnTreadmill"
        android:layout_width="129dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:layout_marginLeft="180dp" 
        android:layout_centerVertical="true"/>

<!--
End Relative Layout
-->
    </RelativeLayout>

    <TextView
        android:id="@+id/treadmilltext"
        android:layout_width="91dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:text="@string/treadmill"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

<!--
Begin Relative Layout
-->

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/stepperimage"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/stepper" />

    <EditText
        android:id="@+id/durOnStepper"
        android:layout_width="129dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:layout_marginLeft="180dp" 
        android:layout_centerVertical="true"/>

<!--
End Relative Layout
-->
    </RelativeLayout>

    <TextView
        android:id="@+id/steppertext"
        android:layout_width="91dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:text="@string/stepper"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

<!--
Begin Relative Layout
-->
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/stationaryrowing"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/stationaryrowing" />

    <EditText
        android:id="@+id/durOnStationaryRowing"
        android:layout_width="129dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:layout_marginLeft="180dp" 
        android:layout_centerVertical="true"/>

<!--
End Relative Layout
-->
    </RelativeLayout>

    <TextView
        android:id="@+id/stationaryrowingtext"
        android:layout_width="91dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:text="@string/stationaryrowing"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

<!--
Begin Relative Layout
-->
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/exercisebikeimage"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/excerisebike" />

    <EditText
        android:id="@+id/durOnexcerisebike"
        android:layout_width="129dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:layout_marginLeft="180dp" 
        android:layout_centerVertical="true"/>

 <!--
End Relative Layout
-->
    </RelativeLayout>

     <TextView
        android:id="@+id/excerisebiketext"
        android:layout_width="91dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:text="@string/exercisebike"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

 <!--
Begin Relative Layout
-->
       <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/ellipticaltrainerimage"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/ellipticaltrainer" />

    <EditText
        android:id="@+id/durOnellipticaltrainer"
        android:layout_width="129dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:layout_marginLeft="180dp" 
        android:layout_centerVertical="true"/>

<!--
End Relative Layout
-->
    </RelativeLayout>

        <TextView
        android:id="@+id/ellipticaltrainertext"
        android:layout_width="91dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:text="@string/ellipticaltrainer"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

<!--
End Linear Layout
-->
</LinearLayout>   

以下所有内容的周TextView的1 都必须在滚动型

在此先感谢,才会真正AP preciate所有的答案:)

Thanks in advance, will really appreciate all the answers :)

推荐答案

只是把scorolleview为RelativeLayout的母公司如下:

just put the scorolleview as parent of the RelativeLayout as follows:

<ScrollView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:scrollHorizontally="true">

    <ImageView
        android:id="@+id/treadmillimage"
        android:layout_width="115dp"
        android:layout_height="93dp"
        android:paddingTop="10dp"
        android:src="@drawable/treadmill" />

.....
.....
</RelativeLayout>
</ScrollView>

这篇关于加入线性和相对布局滚动型在一个XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆