草庐IT

android,scrollview 中 textview 的最后一行略有截断

coder 2023-12-09 原文

textview 的最后一行被稍微截断了。较大和下方的字母被截断(g、j、y ...)。我发现或尝试过的解决方案都没有奏效,比如添加填充、边距、删除 layout_gravity ... 当更改文本并设置多行而不是默认字符串时会发生这种情况。

下面的代码在 FrameLayout 中。

<RelativeLayout
android:id="@+id/window"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black">

<RelativeLayout
    android:id="@+id/action_bar"
    android:layout_alignParentTop="true"
    android:layout_width="fill_parent"
    android:layout_height="46dp"
    android:background="@color/royal_blue" >

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="38dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_vertical|left"
        android:layout_margin="4dp"
        android:background="@drawable/ic_launcher" />

    <View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:id="@+id/space"
    android:background="@color/royal_blue"
    android:layout_toLeftOf="@+id/selectLeft"
    android:layout_toRightOf="@+id/imageView" />

    <Button
        android:id="@+id/buttonOptions"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="33dp"
        android:layout_height="33dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_vertical|center_horizontal"
        android:background="@drawable/ic_action_overflow"
        android:gravity="right" />


        <TextView
            android:id="@+id/selectLeft"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_toLeftOf="@+id/selectRight"
            android:layout_marginRight="4dp"



            android:gravity="center"
            android:textColor="@color/white"
            android:textSize="20sp" />
        <TextView
            android:id="@+id/selectRight"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_toLeftOf="@+id/buttonOptions"
            android:layout_marginRight="2dp"
            android:layout_marginLeft="4dp"

            android:gravity="center"
            android:textColor="@color/white"
            android:textSize="20sp" />


</RelativeLayout>

<View
    android:id="@+id/action_bar_shadow"                
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:layout_below="@+id/action_bar"
    android:background="@color/darker_blue" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:layout_marginBottom="4dp"
    android:layout_below="@+id/action_bar_shadow"                
    android:background="@color/black"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="48dp" >

        <EditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="4dp"
            android:layout_marginTop="4dp" />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="8dp">

        <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="10dp"
        android:text="@string/IntroduceWord"
        android:layout_marginLeft="4dp"
        android:textColor="@color/white"
        android:textSize="17sp" />
    </ScrollView>

</LinearLayout>

<ImageView
    android:id="@+id/resize"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="Resize"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:adjustViewBounds="true"
    android:paddingRight="-8dp"
    android:paddingBottom="-0dp"
    android:layout_marginBottom="-8dp"
    android:layout_marginRight="-1dp"
    android:src="@drawable/corner_blue" />
<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_margin="0dp"
    android:layout_alignParentBottom="true"
    android:background="@color/royal_blue" />

最佳答案

对于 ScrollView 中的 TextView,添加 android:paddingBottom="10dip" 它会完美地工作。您可以为填充赋予任何值。

关于android,scrollview 中 textview 的最后一行略有截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21429382/

有关android,scrollview 中 textview 的最后一行略有截断的更多相关文章

  1. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  2. ruby - Hanami link_to 助手只呈现最后一个元素 - 2

    我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm

  3. ruby - 如果它是标点符号,我怎么能从字符串中删除最后一个字符,在 ruby​​ 中? - 2

    啊,正则表达式有点困惑。我正在尝试删除字符串末尾所有可能的标点符号:ifstr[str.length-1]=='?'||str[str.length-1]=='.'||str[str.length-1]=='!'orstr[str.length-1]==','||str[str.length-1]==';'str.chomp!end我相信有更好的方法来做到这一点。有什么指点吗? 最佳答案 str.sub!(/[?.!,;]?$/,'')[?.!,;]-字符类。匹配这5个字符中的任何一个(注意,。在字符类中并不特殊)?-前一个字符或组

  4. Ruby - 删除文件中的最后一个字符? - 2

    看起来一定很简单,但我就是想不通。如何使用RubyIO删除文件的最后一个字符?我查看了deletingthelastlineofafile的答案使用Ruby但没有完全理解它,必须有更简单的方法。有什么帮助吗? 最佳答案 有File.truncate:truncate(file_name,integer)→0Truncatesthefilefile_nametobeatmostintegerbyteslong.Notavailableonallplatforms.所以你可以这样说:File.truncate(file_name,Fil

  5. ruby-on-rails - Ruby on Rails 的最后 20% - 2

    我是(相当)一位经验丰富的程序员,但对Ruby和RubyonRails完全陌生。RoR看起来很适合快速工作,特别是用于CRUD操作的自动屏幕生成。它确实能让您快速提高工作效率。问题是最后20%的工作,那时我必须完成我的申请。RoR公约不会妨碍我吗?因为不是每个数据库表都必须对所有用户可用,也不是所有用户都可以编辑所有列和/或所有行,而且View必须适应我网站的外观等。我知道RoR已成功用于现场,但在第一阶段烧毁后,如何在RoR中获得足够的速度以逃避重力。 最佳答案 我认为脚手架无法让您达到80%。脚手架很好,因为它向您展示了Rail

  6. Ruby Regex,获取所有可能的匹配项(不截断字符串) - 2

    我遇到了ruby​​正则表达式的问题。我需要找到所有(可能重叠的)匹配项。这是问题的简化:#Simpleexample"Hey".scan(/../)=>["He"]#Actualresults#Withoverlappingmatchestheresultshouldbe=>["He"],["ey"]我尝试执行并获得所有结果的正则表达式如下所示:"aaaaaa".scan(/^(..+)\1+$/)#Thislooksformultiplesof(here)"a"biggerthanonethat"fills"theentirestring."aa"*3=>true,"aaa"*2=

  7. arrays - 在一行中选择数组的第一个和最后一个元素 - 2

    我的任务是从数组中选择最高和最低的数字。我想我很清楚我想做什么,但只是努力以正确的格式访问信息以满足通过标准。defhigh_and_low(numbers)array=numbers.split("").map!{|x|x.to_i}array.sort!{|a,b|ba}putsarray[0,-1]end数字可能看起来像"80917234100",要通过,我需要输出"9234"。我正在尝试putsarray.first.last,但一直无法弄明白。 最佳答案 有Array#minmax完全满足您需要的方法:array=[80,

  8. ruby - 如何使用 Ruby 从 CSV 中删除一行 - 2

    给定以下CSV文件,您将如何删除列“foo”中包含单词“true”的所有行?Date,foo,bar2014/10/31,true,derp2014/10/31,false,derp我有一个可行的解决方案,但它需要制作一个辅助CSV对象csv_no_foo@csv=CSV.read(@csvfile,headers:true)#http://bit.ly/1mSlqfA@headers=CSV.open(@csvfile,'r',:headers=>true).read.headers#MakeanewCSV@csv_no_foo=CSV.new(@headers)@csv.eachd

  9. 一行中的 while block 的 Ruby 语法 - 2

    请问,一行whileblock的Ruby语法是什么? 最佳答案 例如putsa[i+=1]whilei 关于一行中的whileblock的Ruby语法,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/21712232/

  10. ruby - 如何将文本文件读入数组数组(每个子数组都是文本文件中的一行?) - 2

    所以我在Ruby方面几乎是个新手,我整理了一个代码来解决MinCut问题(对于一个作业,是的——我整理并测试了那部分代码),并且我无法弄清楚如何读取文件并将其放入数组数组中。我有一个文本文件要阅读,其中包含不同长度的列,如下所示137791642123134348123134109我想将它读入一个二维数组,其中每一行和每一列都被拆分,每一行都进入一个数组。因此,上述示例的结果数组将是:[[1,37,79,164],[2,123,134],[3,48,123,134,109]]我读取文本文件的代码如下:defread_array(file,count)int_array=[]File.f

随机推荐