【问题标题】:Android - Text wraps in designer and emulator but not on deviceAndroid - 文本在设计器和模拟器中换行,但不在设备上
【发布时间】:2013-10-07 02:26:04
【问题描述】:

初级 Android 开发人员。我正在使用 Eclipse 编写和设计应用程序。

突然,TextViews 停止在我的物理 Android 设备上换行文本。警报对话框也不再换行。包装在设计器和模拟器中正常工作。

我上次测试时,它们正确包裹在设备上。自从这样做以来,我只添加了一个带有几个按钮的新活动。我不相信我对主菜单活动进行了任何更改,如下所示:

<ScrollView 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">

<RelativeLayout
android:id="@+id/textViewRedeem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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=".ActivityMainMenu" >

<Button
    android:id="@+id/buttonQuickStart"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:onClick="handleQuickStart"
    android:text="@string/buttonQuickStart" />
<Button
    android:id="@+id/buttonLoad"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textViewLoad"
    android:layout_alignRight="@+id/buttonQuickStart"
    android:layout_below="@+id/textViewNew"
    android:layout_marginTop="18dp"
    android:onClick="handleLoad"
    android:text="@string/buttonLoad" />

<Button
    android:id="@+id/buttonRedeemCode"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textViewLoad"
    android:layout_below="@+id/textViewLoad"
    android:layout_marginTop="14dp"
    android:onClick="handleRedeem"
    android:text="@string/buttonRedeemCode" />

<Button
    android:id="@+id/buttonNew"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textViewQuickStart"
    android:layout_alignRight="@+id/buttonQuickStart"
    android:layout_below="@+id/textViewQuickStart"
    android:layout_marginTop="18dp"
    android:onClick="handleNew"
    android:text="@string/buttonNew" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/buttonRedeemCode"
    android:layout_below="@+id/buttonRedeemCode"
    android:text="@string/defineRedeem"
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:singleLine="false"/>
<TextView 
    android:id="@+id/textViewQuickStart" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/buttonQuickStart" 
    android:layout_below="@+id/buttonQuickStart" 
    android:text="@string/defineQuickStart" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:singleLine="false"/>
<TextView android:id="@+id/textViewNew" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/buttonNew" 
    android:layout_below="@+id/buttonNew" 
    android:text="@string/defineNew" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:singleLine="false"/>
<TextView 
    android:id="@+id/textViewLoad" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textViewNew" 
    android:layout_below="@+id/buttonLoad" 
    android:text="@string/defineLoad" 
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:singleLine="false" />

我使用的 AVD 是带有 Android 4.3 的 3.2" HVGA 滑块。我正在测试应用程序的实际设备是带有 Android 2.3.6 和 3.65" 屏幕的三星 S7500L。

【问题讨论】:

    标签: android xml eclipse textview word-wrap


    【解决方案1】:
    // try this
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                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=".ActivityMainMenu" >
    
        <LinearLayout
                android:id="@+id/textViewRedeem"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginTop="5dp"
                android:orientation="vertical">
    
            <Button
                    android:id="@+id/buttonQuickStart"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:onClick="handleQuickStart"
                    android:text="@string/buttonQuickStart" />
    
            <TextView
                    android:id="@+id/textViewQuickStart"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/defineQuickStart"
                    android:textAppearance="?android:attr/textAppearanceMedium"/>
    
            <Button
                    android:id="@+id/buttonNew"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="18dp"
                    android:onClick="handleNew"
                    android:text="@string/buttonNew" />
    
            <TextView android:id="@+id/textViewNew"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="@string/defineNew"
                      android:textAppearance="?android:attr/textAppearanceMedium"/>
    
            <Button
                    android:id="@+id/buttonLoad"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="18dp"
                    android:onClick="handleLoad"
                    android:text="@string/buttonLoad" />
    
            <TextView
                    android:id="@+id/textViewLoad"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/defineLoad"
                    android:textAppearance="?android:attr/textAppearanceMedium"/>
    
            <Button
                    android:id="@+id/buttonRedeemCode"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="14dp"
                    android:onClick="handleRedeem"
                    android:text="@string/buttonRedeemCode" />
    
            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/defineRedeem"
                    android:textAppearance="?android:attr/textAppearanceMedium"/>
        </LinearLayout>
    
    </ScrollView>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 1970-01-01
      • 2013-08-13
      • 2018-10-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多