简体   繁体   English

Android:水平LinearLayout中的多行TextView

[英]Android: Multiline TextView in Horizontal LinearLayout

I want to add a multiline TextView in my LinearLayout. 我想在我的LinearLayout中添加多行TextView。 Following is my code but it is not working. 以下是我的代码,但无法正常工作。 On device it just shows single line. 在设备上,它仅显示单行。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:gravity="right"
  android:orientation="horizontal">
  <ImageView
     android:id="@+id/file_picker_image"
     android:layout_width="40dip"
     android:layout_height="40dip"
     android:layout_marginTop="10dip"
     android:layout_marginBottom="5dip"
     android:layout_marginLeft="5dip"
     android:src="@drawable/file"
     android:scaleType="centerCrop"/>

  <TextView
     android:id="@+id/file_picker_text"
     android:layout_width="fill_parent"
     android:layout_height="60dip"
     android:layout_weight="1"
     android:layout_gravity="left|center_vertical"
     android:textSize="18sp"
     android:layout_marginLeft="10dip"
     android:layout_marginRight="10dip"
     android:layout_marginTop="10dip"
     android:singleLine="false" 
     android:maxLines="2"
     android:lines="2"
     android:text="Multiline text here"/>

</LinearLayout>

它对我来说效果很好,请尝试在文本中添加更多字符,例如:

android:text="Multiline text here with more characters uhuuuuu"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM