How to auto break line in android xml?

mc 3,461 Reputation points
2021-05-27T07:01:21.81+00:00

in xamarin.forms android I created a xml to show text. but sometimes the text was too long that the view will over screen.

how to make it auto fit the screen ?

the code is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
  <LinearLayout android:orientation="vertical"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@xml/shape_corner">
    <TextView
      android:text="PoInfoWindow"
      android:gravity="bottom | center_horizontal"
      android:background="#ffffff"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:layout_marginTop="14dp"
      android:layout_marginBottom="14dp"
      android:layout_marginRight="38dp"
      android:layout_marginLeft="38dp"
      android:textColor="#51667f"
      android:textSize="15dp"
      android:id="@+id/title"
        />
  </LinearLayout>
</LinearLayout>

I will put value to the id title
can it be multi lines if the text is too long?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,258 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 64,011 Reputation points Microsoft Vendor
    2021-05-27T08:27:55.153+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    I used your code(I do not have @xml/shape_corner ), textview have auto break line. I do not add any code, here is running screenshot.

    100080-image.png

    If you project have this issue, could you provide a demo that could reproduce this issue?

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful