如何使文本布局不超出螢屏
我有一個程式,我需要在其中添加換行符textlayout,但是當我添加\n到它一定次數時,文本超出了螢屏。那么這里是如何解決它?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:background="#000000"
tools:context=".MainActivity">
<EditText
android:id="@ id/editText"
android:layout_width="351dp"
android:layout_height="46dp"
android:layout_toLeftOf="@ id/button"
android:fontFamily="monospace"
android:hint="Command"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toStartOf="@ id/button"
app:layout_constraintTop_toTopOf="@ id/guideline"></EditText>
<TextView
android:id="@ id/textView"
android:layout_width="378dp"
android:layout_height="657dp"
android:layout_marginEnd="16dp"
android:fontFamily="monospace"
android:gravity="top|right"
android:text="Hello World!"
android:textColor="#FFFFFF"
app:layout_constraintBottom_toTopOf="@ id/guideline"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@ id/button"
android:layout_width="100px"
android:layout_height="100px"
android:layout_marginEnd="16dp"
android:background="#000000"
android:text="?"
android:fontFamily="monospace"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@ id/guideline" />
<android.support.constraint.Guideline
android:id="@ id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="658dp" />
</android.support.constraint.ConstraintLayout>
uj5u.com熱心網友回復:
建議使用 match_parent 或 wrap_content 或者您可以使用 0dp 根據約束縮放視圖。我建議使用 0dp 作為寬度(根據您的要求縮放)和 wrap_cotent 作為寬度
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/522123.html
標籤:安卓安卓布局
