gpt4 book ai didi

android - 文字被截断。安卓

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:39:01 24 4
gpt4 key购买 nike

当我的文本超过一行时,我的文本在应用程序中被截断了。它只发生在 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,这是第一行文本的底部,这解释了为什么只有当您有多行文本时才会出现此问题。

因此,您可以为包含 TextViewButton< 的 LinearLayout 设置 android:baselineAligned="false"/.

有关 baselineAligned 属性的概述,请参阅本文:TechoTalkative article by Paresh Mayani .


您可以使用 RelativeLayout 而不是这么多具有​​权重属性的嵌套 LinearLayout(由于测量 View 边界所需的多次传递会降低性能)。

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

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

关于android - 文字被截断。安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18399351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com