文字被截断。安卓

用户名

当我的文字超过一行时,在应用程序中被截断。它仅发生在hdpi或以下的手机上。任何帮助将是巨大的。

代码:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
                android:background="@drawable/backgroundp" >


<com.example.app.ObservableScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        <View
            android:id="@+id/placeholder"
            android:layout_width="match_parent"
            android:layout_height="@dimen/sticky_height" />

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingTop="10dip" >
                </LinearLayout>

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

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="Man what you doing that for. Come on"
                        android:textSize="20sp" />

                    <Button
                        android:id="@+id/button02"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Play" />
                </LinearLayout>

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

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="Come on Man. Just Stop, no need for that."
                        android:textSize="20sp" />

                    <Button
                        android:id="@+id/button03"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Play" />
                </LinearLayout>

               Lots of the same thing over and over again. 

          Then


      </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
 </com.example.app.ObservableScrollView>

 <Button
    android:id="@+id/button01"
    style="@style/Item.Sticky"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Stop" 
    android:paddingLeft="10dp"
            android:paddingRight="10dp"
                    android:paddingTop="10dp"/>

            </FrameLayout>

下面还有更多东西,但是我猜这是您真正需要看到的东西。如果布局高度是自动换行内容,那就不行了。我猜这是文本大小,但不确定吗?

原子

以下是可接受的答案。

我认为“真实”的答案是默认情况下LinearLayout具有baselineAligned属性true这意味着它将根据其定义的“基准”将其子项对齐。对于TextViews,这是第一行文本的底部,这解释了为什么只有在多行文本时才会出现此问题。

因此,您可以将设置android:baselineAligned="false"为,LinearLayout其中包含TextViewButton

有关此baselineAligned属性的概述,请参见本文Paresh Mayani的TechoTalkative文章


您可以使用RelativeLayout来代替具有weight属性的许多嵌套LinearLines布局(由于测量视图边界需要多次通过,因此会降低性能)。

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

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Come on Man. Just Stop, no need for that."
        android:textSize="20sp"
        android:layout_alignParentLeft="true"
        />

    <Button
        android:id="@+id/button03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="Play"/>

</RelativeLayout>

在我的测试中,这没有得到剪切的文本。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章