App crashing after adding a ScrollView and ImageView

前提是你 提交于 2019-12-20 04:47:42

问题


I added a scroll element to the main activity of my application along with an ImageView but when I ran the project on an emulator it crashes giving me errors stemming from the main activity.The error log is a follows: http://pastebin.com/PAYrjHCL

So from going through the errors I found that it was a problem in the main activity.But I don't see where I have gone wrong as I only added these two features.Can anyone spot whats wrong in this activity thats causing it to crash?

My main_activity is like this:

<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"
    android:fillViewport="true"
    android:gravity="center_vertical"
    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"
     >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

<EditText
    android:id="@+id/ductDepth"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/calc"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="37dp"
    android:ems="10"
    android:hint="@string/enter_duct_depth_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/offDepth"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView3"
    android:layout_alignLeft="@+id/ductDepth"
    android:layout_marginBottom="14dp"
    android:ems="10"
    android:hint="@string/enter_offset_depth_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" />

<EditText
    android:id="@+id/offLength"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignLeft="@+id/offDepth"
    android:layout_marginBottom="20dp"
    android:ems="10"
    android:hint="@string/enter_offset_length_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/offDepth"
    android:layout_alignLeft="@+id/offDepth"
    android:text="Depth:"
    android:textSize="30sp" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ductDepth"
    android:layout_alignLeft="@+id/ductDepth"
    android:text="Duct Depth:"
    android:textSize="30sp" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/offLength"
    android:layout_alignLeft="@+id/offLength"
    android:text="Length:"
    android:textColor="@style/AppTheme"
    android:textSize="30sp" />

<Button
    android:id="@+id/calc"
    android:layout_width="200dp"
    android:layout_height="70dp"
    android:layout_alignLeft="@+id/ductDepth"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="30dp"
    android:background="@drawable/calcbttrans" />



<android.support.v4.view.ViewPager     
android:id="@+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/calc" >

<!--
This title strip will display the currently visible page title, as well as the page
titles for adjacent pages.
-->

<android.support.v4.view.PagerTitleStrip
    android:id="@+id/pager_title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#33b5e5"
    android:paddingBottom="4dp"
    android:paddingTop="4dp"
    android:textColor="#fff" />

</android.support.v4.view.ViewPager>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="700dp"
    android:layout_above="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="84dp"
    android:src="@drawable/mark3" />

</RelativeLayout>

</ScrollView>

来源:https://stackoverflow.com/questions/19966201/app-crashing-after-adding-a-scrollview-and-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!