草庐IT

Android ConstraintLayout TextView 跳出屏幕

coder 2023-11-19 原文

正如您在图片中看到的那样,文字不在墙上。这是一个非常奇怪的行为,我认为这是一个错误

这是一个屏幕截图:

这是标题 xml:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/windowBackground"
    android:orientation="vertical">

    <TextView
        android:id="@+id/street_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="15dp"
        android:text="street name"
        android:textColor="?AppTheme.InformationText"
        android:textSize="14sp"
        android:textStyle="bold"
        android:gravity="center"
        android:layout_marginTop="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="19dp"
        android:layout_marginLeft="0dp"
        app:layout_constraintWidth_default="wrap"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="@+id/guideline29"
        app:layout_constraintTop_toTopOf="@+id/guideline37"
        app:layout_constraintRight_toLeftOf="@+id/guideline30"
        app:layout_constraintHorizontal_bias="0.605"
        app:layout_constraintVertical_bias="0.0"/>

    <ImageView
        android:id="@+id/street_view_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:padding="6dp"
        android:scaleType="fitCenter"
        tools:layout_constraintLeft_creator="1"
        android:layout_marginLeft="0dp"
        app:layout_constraintLeft_toLeftOf="@+id/country_flag_image"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="0dp"
        app:layout_constraintRight_toLeftOf="@+id/guideline29"
        android:layout_marginRight="8dp"
        app:layout_constraintTop_toTopOf="@+id/guideline37"
        android:layout_marginTop="8dp"/>

    <ImageView
        android:id="@+id/country_flag_image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginLeft="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="8dp"
        android:adjustViewBounds="true"
        android:paddingBottom="5dp"
        android:paddingLeft="5dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintTop_creator="1"
        />

    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/exit_image"
        android:layout_width="46dp"
        android:layout_height="46dp"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="-4dp"
        android:src="@drawable/exit_custom"
        app:border_color="#FF000000"
        app:layout_constraintBottom_toBottomOf="@+id/street_view_image"
        app:layout_constraintRight_toRightOf="@+id/street_view_image"
        tools:layout_constraintBottom_creator="1"
        tools:layout_constraintRight_creator="1"
        />

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline29"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.5"/>

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline30"
        app:layout_constraintGuide_begin="395dp"
        android:orientation="vertical"/>

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline37"
        app:layout_constraintGuide_begin="8dp"
        android:orientation="horizontal"/>

</android.support.constraint.ConstraintLayout>

如何让名为 street_nameTextView 文本不显示在屏幕外? 我用 MaterialDrawer但我认为这与此无关。 设备是装有 Android 6.0.1 的三星 Note 4。在 Android Studio 2.3.3 中使用 ConstraintLayout 版本 com.android.support.constraint:constraint-layout:1.0.2

最佳答案

street_name 设置 android:layout_width="0dp"。这将导致它匹配约束并应将其保持在界限内。

不工作? street_nameguideline30 限制在右侧 395dp395dp 是否在屏幕右侧?

关于Android ConstraintLayout TextView 跳出屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46350501/

有关Android ConstraintLayout TextView 跳出屏幕的更多相关文章

  1. 屏幕录制为什么没声音?检查这2项,轻松解决 - 2

    相信很多人在录制视频的时候都会遇到各种各样的问题,比如录制的视频没有声音。屏幕录制为什么没声音?今天小编就和大家分享一下如何录制音画同步视频的具体操作方法。如果你有录制的视频没有声音,你可以试试这个方法。 一、检查是否打开电脑系统声音相信很多小伙伴在录制视频后会发现录制的视频没有声音,屏幕录制为什么没声音?如果当时没有打开音频录制,则录制好的视频是没有声音的。因此,建议在录制前进行检查。屏幕上没有声音,很可能是因为你的电脑系统的声音被禁止了。您只需打开电脑系统的声音,即可录制音频和图画同步视频。操作方法:步骤1:点击电脑屏幕右下侧的“小喇叭”图案,在上方的选项中,选择“声音”。 步骤2:在“声

  2. ruby-on-rails - 在服务器端检测屏幕尺寸和像素密度? - 2

    我一直在做一些研究,我想我已经知道答案了,但我想知道是否有任何方法可以在不使用javascript或依赖CSS3媒体的情况下获得设备的屏幕尺寸和像素密度查询。本质上,我正在研究如何获取屏幕分辨率和像素密度,以便服务器可以决定在URI请求中为服务器提供哪个图像。到目前为止,我还没有发现任何证据表明这是可能的,但我想嘿,为什么不问问呢? 最佳答案 我不完全同意上面的正确答案。实际上,这个答案在很多情况下都是正确的……但理论上并非如此。通常向Web服务器发出的请求包含一个User-Agent字段,从理论上讲,该字段可用于识别有关设备屏幕分

  3. ruby - 以编程方式在 Ruby 中获取桌面的屏幕截图? - 2

    我问了这个关于takingapictureofawebpageprogrammatically的问题,我已经下载并获得了webkit2png工作(为博客等HTML页面拍照)。太酷了,谢谢你给我看!现在我想开始做更多的事情,比如能够在加载Flash网站和我的桌面后拍照。是否可以使用webkit2png为Flash网站拍照(考虑到您可能需要等待几秒钟才能加载)?但主要问题是,如何以编程方式为桌面拍照?这将使我能够更好地控制正在发生的事情。 最佳答案 您可以使用xwd(1)获取根窗口的屏幕截图:xwd-display:0-root|xwd

  4. ruby - (Watir webdriver) 在 OSX 10.9 中使用多显示器时如何将浏览器移动到另一个屏幕 - 2

    我知道有一个名为browser.window.move_to(0,0)的函数可以将浏览器移动到不同的位置,但OSX10.9对它来说是全新的。有什么方法可以将浏览器移动到另一个桌面吗?例如。在“桌面2”中触发命令的控制台,但我希望浏览器出现在“桌面1”中。非常感谢! 最佳答案 哈,在我尝试这个之前我正要说这可能是不可能的:browser.window.move_to(-1200,0)我的第二台显示器位于主屏幕的左侧。有效。好问题。您需要花点时间才能正确使用它,但watir似乎能够使用整个显示器Canvas。例如,如果您的显示器位于主屏

  5. ruby - 如何使用 ruby​​ 和 unix 服务器截取网页的屏幕截图? - 2

    关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭7年前。Improvethisquestion我正在尝试以编程方式创建大量网页的缩略图,这些网页托管在我自己的基于ruby​​/rails的网站上。我希望能够编写一个独立的ruby​​代码,看起来像这样:require'awesome-screenshot-maker'items.eachdo|id|url="http://foo.com/bar/#{id}"shooter=AwesomeScreenshotMa

  6. ruby-on-rails - 在 rake 任务中打印到屏幕 - 2

    我有一个长时间运行的rake任务。我时不时地在屏幕上打印更新,让我知道任务已经完成了多长时间。puts"Almostthere..."我的问题是所有puts语句似乎都缓冲在某处,直到任务完成后才会打印到屏幕上。届时,它们将被一次性全部打印出来。有什么方法可以强制他们在任务运行时打印吗? 最佳答案 STDOUT.sync=true 关于ruby-on-rails-在rake任务中打印到屏幕,我们在StackOverflow上找到一个类似的问题: https://

  7. ruby-on-rails - 在不使用屏幕的情况下在后台运行 ruby​​ 脚本 - 2

    我在Rails环境中有两个必须全天候运行的脚本。我在远程服务器上工作,所以我需要使用ssh启动脚本,这意味着我需要一直打开ssh窗口。我正在寻找一种在后台运行这些脚本的简单方法,这样它们就不会在我关闭ssh连接后立即被取消。我不想使用屏幕。我认为必须有更简单的方法来处理这个问题。不是吗? 最佳答案 我认为最基本的解决方案是nohup:nohupmyscript&>/dev/null& 关于ruby-on-rails-在不使用屏幕的情况下在后台运行ruby​​脚本,我们在StackOver

  8. ruby - 使用 ruby​​ 的特定 dom 元素的屏幕截图 - 2

    有没有办法做到this使用capybara+phantomjs。或者更复杂的东西,比如将整页屏幕截图裁剪到特定的dom元素? 最佳答案 Apullrequest已提交此功能。即将关闭,您将可以使用driver.renderselector:'#some_id`在下一个版本中。 关于ruby-使用ruby​​的特定dom元素的屏幕截图,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/

  9. ruby - 如何使用 Ruby 将 STDOUT 复制到文件而不停止它在屏幕上显示 - 2

    我正在尝试将标准输出复制到一个文件以用于日志记录。我还希望它显示在我正在使用的IDE的Ruby控制台中。我将这段代码插入到我的脚本中,它将$stdout重定向到my.log文件:$stdout.reopen("my.log","w")有没有人知道将$stdout的内容复制到文件而不是将其重定向到文件的gem或技术?另外,我不使用Rails,只使用Ruby。 最佳答案 这样的事情可能对你有帮助:classTeeIOIO中大部分做输出的方法最终都是使用write,所以你只需要重写这一个方法即可。你可以像这样使用它:#setuptee=T

  10. android 多屏幕显示activity,副屏,无线投屏 - 2

    目录1.首先,需要一个副屏1.1可以通过代码的形式自己创建VirtualDispaly,创建副屏。1.2或者,在手机的开发者模式中直接开启模拟副屏,也是可以的。2.0怎么利用这个副屏幕?2.1 用作presentation演示ppt:2.2克隆主屏幕的内容,就是主屏幕显示什么,副屏显示同样的内容,镜像模式。2.3 将一个activity从第二个屏幕上启动,作为一个独立的屏幕首先说明一下这个多屏幕的概念,这里不是指分屏显示。分屏显示:是一个屏幕分出多个窗口,分别显示不同app.多屏支持:是一个设备有多个屏幕,怎么让不同的屏幕显示不同的app,或者是一个app同时用两个屏幕来显示不同的页面内容。多

随机推荐