无法采用Android获得滚动在设备S3? [英] Failed to get Scrolling in device S3 using Android?

查看:101
本文介绍了无法采用Android获得滚动在设备S3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的XML codeI想申请在滚动查看,但没有滚动出现在我的设备screen.Here是XML Layout.Can有人请我提出可能的解决方案来克服这种局面.....

 <?XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@绘制/ home_bg
    机器人:方向=垂直>    <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直>
        <的LinearLayout
            机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直>        < ImageView的
            机器人:ID =@ + ID / askfatwa_header
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:SRC =@绘制/ askfatwa_top_bar/>
< / LinearLayout中>
        <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ ID / askfatwa_header
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
            机器人:layout_marginTop =5DP
            机器人:方向=垂直>            <的TextView
                机器人:ID =@ + ID / name_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字=@字符串/名
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/>            <的EditText
                机器人:ID =@ + ID / askscreen_name
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:paddingLeft =5DP
                机器人:MAXLINES =1
                安卓的inputType =TEXT                机器人:背景=@绘制/文本框>
            < /&的EditText GT;
        < / LinearLayout中>        <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
             机器人:layout_marginTop =5DP
            机器人:方向=垂直>            <的TextView
                机器人:ID =@ + ID / email_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT                机器人:文字=@字符串/邮件
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/>            <的EditText
                机器人:ID =@ + ID / askscreen_email
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:MAXLINES =1
                安卓的inputType =textEmailAddress
                  机器人:背景=@绘制/文本框
                机器人:paddingLeft =5DP/>
        < / LinearLayout中>        <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
             机器人:layout_marginTop =5DP
            机器人:方向=垂直>            <的TextView
                机器人:ID =@ + ID / address_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT                机器人:文字=@字符串/地址
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/>            <的EditText
                机器人:ID =@ + ID / askscreen_address
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:paddingLeft =5DP
                安卓的inputType =textMultiLine                机器人:背景=@绘制/文本框/>
        < / LinearLayout中>
        <! - <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
             机器人:layout_marginTop =5DP
            机器人:方向=垂直>            <的TextView
                机器人:ID =@ + ID / contact_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字=@字符串/联系人
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/>            <的EditText
                机器人:ID =@ + ID / askscreen_contact
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:paddingLeft =5DP
                  机器人:背景=@绘制/文本框/>
        < / LinearLayout中> - >        <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
             机器人:layout_marginTop =5DP
            机器人:方向=垂直>            <的TextView
                机器人:ID =@ + ID / subject_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文字=@字符串/主题
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/>            <! - <的EditText
                机器人:ID =@ + ID / askscreen_subject
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:paddingLeft =5DP/> - >
                <微调
                机器人:ID =@ + ID / askscreen_subject
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:paddingLeft =5DP/>
        < / LinearLayout中>
         <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =15dp
            机器人:layout_marginRight =15dp
            机器人:layout_marginTop =5DP
            机器人:方向=垂直>           <! - <的TextView
                机器人:ID =@ + ID / body_askscreen
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:提示=输入您的问题
                机器人:文字颜色=@机器人:彩色/白
                机器人:TEXTSIZE =20SP/> - >            <的EditText
                机器人:ID =@ + ID / askscreen_question
                机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =3DP
                机器人:背景=@绘制/文本框
                机器人:提示=输入您的问题
                安卓的minlines =1
                安卓的inputType =textMultiLine
                安卓了minHeight =8DP
                安卓了minWidth =10dp
                机器人:行=15
                机器人:paddingLeft =5DP/>        < / LinearLayout中>
        < ImageView的
            机器人:ID =@ + ID / askscreen_submit_btn
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =中心
            机器人:layout_marginTop =10dp
            机器人:paddingTop =20dp
            机器人:SRC =@绘制/ askftwa_submit_button/>
    < / LinearLayout中>< /滚动型>


解决方案

 首先跌倒通过看你的XML,你正在创建非常昂贵的布局含
许多不必要的线性布局,即当你的所有视图方向垂直。
你为什么要定义在不同的线性布局你的观点一样文本框和EditText上,
它产生的性能问题。其次,你不应该定义设置滚动视图任何背景和方向。
默认情况下滚动视图的方向是垂直的。虽然我只是在我的模拟器一些改变其工作罚款运行code
我的设备上。< XML版本=1.0编码=UTF-8&GT?;
<滚动型
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>    //这是包含所有子视图主要布局    <的LinearLayout
      机器人:layout_width =match_parent
     机器人:layout_height =WRAP_CONTENT
     机器人:背景=@绘制/ home_bg
     机器人:方向=垂直>     //这里定义你的剩余子视图.....
     //而且我可以看到所有的意见都垂直方向的,所以你可以定义所有视图
        这主要布局本身中。
    //因此你可以设置你的观点太边距。
   < / LinearLayout中> < /滚动型>

Here is my xml code i want to apply scrolling in View but no scroll appears in my device screen.Here is the XML Layout.Can someone please suggest me possible solutions to overcome on this situation.....

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/home_bg"
    android:orientation="vertical" >

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

        <ImageView
            android:id="@+id/askfatwa_header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/askfatwa_top_bar" />
</LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/askfatwa_header"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/name_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/name"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <EditText
                android:id="@+id/askscreen_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:paddingLeft="5dp"
                android:maxLines="1"
                android:inputType="text"

                android:background="@drawable/textfield" >
            </EditText>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
             android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/email_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="@string/Email"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <EditText
                android:id="@+id/askscreen_email"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:maxLines="1"
                android:inputType="textEmailAddress"
                  android:background="@drawable/textfield"
                android:paddingLeft="5dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
             android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/address_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:text="@string/Address"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <EditText
                android:id="@+id/askscreen_address"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:paddingLeft="5dp"
                android:inputType="textMultiLine"

                android:background="@drawable/textfield" />
        </LinearLayout>
        <!-- <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
             android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/contact_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Contact"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <EditText
                android:id="@+id/askscreen_contact"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:paddingLeft="5dp"
                  android:background="@drawable/textfield" />
        </LinearLayout> -->

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
             android:layout_marginTop="5dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/subject_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Subject"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

            <!-- <EditText
                android:id="@+id/askscreen_subject"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:paddingLeft="5dp" /> -->
                <Spinner 
                android:id="@+id/askscreen_subject"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:paddingLeft="5dp"/>
        </LinearLayout>
         <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical" >

           <!--   <TextView
                android:id="@+id/body_askscreen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="Type Your Question"
                android:textColor="@android:color/white"
                android:textSize="20sp" />  -->

            <EditText
                android:id="@+id/askscreen_question"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:background="@drawable/textfield"
                android:hint="Type Your Question"
                android:minLines="1"
                android:inputType="textMultiLine"
                android:minHeight="8dp"
                android:minWidth="10dp"
                android:lines="15"
                android:paddingLeft="5dp" />

        </LinearLayout>


        <ImageView
            android:id="@+id/askscreen_submit_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:paddingTop="20dp"
            android:src="@drawable/askftwa_submit_button" />
    </LinearLayout>

</ScrollView>

解决方案

First a fall by seeing your xml, you are creating very expensive layout containing 
unnecessarily many Linear layouts ie when orientation of your all views are vertical.    
Why are you defining your views like textbox and edittext in separate Linear Layouts, 
it creates performance issues.

Secondly, you should not define set any background and orientation in scroll view.
By default orientation of scroll view is vertical.

Although i just run your code with few changes and its working fine on my emulator 
and on my device.



<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    // This is Main layout which contains all your child view 

    <LinearLayout
      android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/home_bg"
     android:orientation="vertical"  >

     // Define your remaining child views here.....
     // And as i can see all views are oriented vertically, so you can define all view 
        inside this Main Layout itself.
    //  Accordingly you can set Margins of your views too.  


   </LinearLayout>

 </ScrollView>

这篇关于无法采用Android获得滚动在设备S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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