滚动型不降低Android版本正确显示其内容 [英] ScrollView doesn't display its content properly in lower versions of android

查看:159
本文介绍了滚动型不降低Android版本正确显示其内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以看到显示我的滚动视图的软糖一样,和放大器;奇巧,非常真棒:

You can see my scrollview being displayed the same in jellybean, & kitkat, very awesome:

输入图像的描述在这里

不过,我吃惊地看到同样的事情在较低的版本像2.2,2.3.3

But I am shocked to see the same thing in lower versions like 2.2, 2.3.3

看来,它显示连接到上限与放大器文本的某些部分;屏幕的底部。

It seems that it display some portion of text attached to upper & bottom portion of screen.

顺便说一句,在中间的线是刚刚与灰色的背景textviews。

BTW, The lines in middle are just the textviews with gray background .

您可以看到我的XML code,对不起它有点长code

You can see my xml code, sorry its a little long code

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/stars"
android:padding="5dp"
android:scrollbars="vertical"
>


<LinearLayout


android:layout_width="match_parent"
android:layout_height="wrap_content"
        android:orientation="vertical" >

 <EditText
     android:id="@+id/editText1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:ems="10"
     android:textColor="#fff"
     android:hint="Type your Full Name here"
     android:inputType="textPersonName"
     android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " >

     <requestFocus />
 </EditText>

 <Button
     android:id="@+id/button1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:background="#330000"
     android:onClick="showresult"
     android:textColor="#ffffff"
     android:alpha=".8"
     android:text="Show My Fortune" />

 <TextView
     android:id="@+id/textView13"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textColor="#ffffff"
     android:textAppearance="?android:attr/textAppearanceSmall" />

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal" 
     android:baselineAligned="false">

     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1" 
         android:orientation="horizontal"
         >

         <TextView
             android:id="@+id/textView1"
             android:layout_width="20dp"
             android:layout_height="wrap_content"
             android:textColor="#ffffff"
             android:textSize="18sp"
              />

         <TextView
             android:id="@+id/textView2"
             android:layout_width="50dp"
             android:layout_height="wrap_content"

             android:textColor="#ffffff"
             android:textSize="18sp" />
     </LinearLayout>

     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" 
         android:orientation="horizontal"
         android:layout_weight="1" >

         <TextView
             android:id="@+id/textView3"
             android:layout_width="20dp"
             android:layout_height="wrap_content"

             android:textColor="#ffffff"
             android:textSize="18sp" />

         <TextView
             android:id="@+id/textView4"
             android:layout_width="50dp"
             android:layout_height="wrap_content"

             android:textColor="#ffffff"
             android:textSize="18sp" />
     </LinearLayout>

     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         android:layout_weight="1"  >

         <TextView
             android:id="@+id/textView5"
             android:layout_width="20dp"
             android:layout_height="wrap_content"
             android:textColor="#ffffff"
             android:textSize="18sp"/>

         <TextView
             android:id="@+id/textView6"
             android:layout_width="50dp"
             android:layout_height="wrap_content"
             android:textColor="#ffffff"
             android:textSize="18sp" />
     </LinearLayout>

 </LinearLayout>

 <TextView
     android:id="@+id/textView7"
     android:layout_width="match_parent"
     android:layout_height=".5dp"

     android:textAppearance="?android:attr/textAppearanceSmall" />

 <TextView
     android:id="@+id/textView8"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
      android:textColor="#ffffff"
     android:textAppearance="?android:attr/textAppearanceSmall" />

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" >

     <TextView
         android:id="@+id/textView9"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textAppearance="?android:attr/textAppearanceLarge"
         android:textColor="#ffffff" />

     <TextView
         android:id="@+id/textView14"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:textColor="#ffffff"
         android:gravity="right"

         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" >

     <TextView
         android:id="@+id/textView10"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textAppearance="?android:attr/textAppearanceLarge"
         android:textColor="#ffffff" />

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

         android:textColor="#ffffff"

         android:gravity="right"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" >

     <TextView
         android:id="@+id/textView11"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textAppearance="?android:attr/textAppearanceLarge"
         android:textColor="#ffffff" />

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

         android:textColor="#ffffff"

         android:gravity="right"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <TextView
     android:id="@+id/textView12"
     android:layout_width="match_parent"
     android:layout_height=".5dp"/>

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" 
     android:orientation="horizontal">

     <TextView
         android:id="@+id/textView17"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#ffffff" 
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView18"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:gravity="right"
         android:textColor="#ffffff"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <TextView
     android:id="@+id/textView19"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textColor="#ffffff"
     android:textAppearance="?android:attr/textAppearanceSmall" />

 <TextView
     android:id="@+id/textView20"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textColor="#ff0000"
     android:textAppearance="?android:attr/textAppearanceLarge" />

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal" >

     <TextView
         android:id="@+id/textView21"
         android:layout_width="40dp"
         android:layout_height="wrap_content"

         android:gravity="right"
         android:textColor="#ff0000"
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView27"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#ffffff"
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView22"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:textColor="#ffff00"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <LinearLayout
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:orientation="horizontal" >

     <TextView
         android:id="@+id/textView23"
         android:layout_width="40dp"
         android:layout_height="wrap_content"
         android:textColor="#ff0000"
         android:gravity="right"
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView28"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#ffffff"
         android:textAppearance="?android:attr/textAppearanceLarge" />

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

         android:textColor="#ffff00"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content" 
     android:orientation="horizontal">

     <TextView
         android:id="@+id/textView25"
         android:layout_width="40dp"
         android:layout_height="wrap_content"
         android:gravity="right"
         android:textColor="#ff0000"
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView29"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#ffffff"
         android:textAppearance="?android:attr/textAppearanceLarge" />

     <TextView
         android:id="@+id/textView26"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textColor="#ffff00"
         android:textAppearance="?android:attr/textAppearanceLarge" />

 </LinearLayout>

</LinearLayout>
</ScrollView>

此外,在GraphicalLayout是显示了这样的警告:

Also in GraphicalLayout is shows this warning :

我希望我解释清楚我的问题!

I hope I explained my problem clearly !

寻找一个答案,

在此先感谢

更新:@semsamot回答后,上述警告是消失了,但问题仍然没有解决。

UPDATE: After @semsamot answer the above warning was disappeared, but the problem is still not solved.

对不起,我的上述code太长,但我有我的应用程序的另一个布局显示了同样的问题。

Sorry, my above code was too long but I have another layout in my app displaying the same problem

考虑这个code:

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/stars"
tools:context="com.vivekwarde.numerologyfortune.MyLuckyNumber"
>
<ScrollView 
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" >

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

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:textColor="#fff"
            android:gravity="center"
            android:onClick="showDatePickerDialog"
            android:text="Birthdate ?"
            android:background="#4c0000" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:textColor="#ffffff"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textColor="#ffffff"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>

</ScrollView>
</RelativeLayout>

如果我显示这个布局简单地将其显示为预计在果冻豆及放大器;奇巧这样的

If I display this layout simply it displays as expected in jelly bean & kitkat like this

不过看到这个输出在2.2和放大器; 2.3.3

But see this output in 2.2 & 2.3.3

为什么的TextView 文本没有按预期正常显示。 ?

Why the text in TextView does not display properly as expected. ?

推荐答案

不要使用浮点值低于1的格式为:.X 相反,使用以下格式:0.X

Don't use float values that lower than 1 in this format: ".x" Instead use this format: "0.x"

如果你改变这些值,你看到的警告消失!

If you change those values you see the warnings disappear!

注意: 还要注意的是在API级别11引入的阿尔法的属性,所以它不会在较低的API(S)工作。

Note: Also note that "alpha" attribute introduced in API Level 11 so it will not work in lower API(s).

这篇关于滚动型不降低Android版本正确显示其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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