Android 水平文本视图忽略新行上的填充或边距
我试图创建一个具有四个垂直Android 水平文本视图忽略新行上的填充或边距,android,android-layout,textview,android-linearlayout,Android,Android Layout,Textview,Android Linearlayout,我试图创建一个具有四个垂直线性布局的视图,每个视图具有两个或三个水平TextView。 我遇到的问题发生在第二个/第三个TextView元素上。当文本太长时,它会“转到”新行,而不是从新行的左侧开始,而是从该元素开始的底部开始 可以在下图中轻松查看问题: 我尝试了RelativeLayout和LinearLayout,修改了TextView填充属性,但没有成功 我的实际布局代码是: <?xml version="1.0" encoding="utf-8"?> <LinearL
线性布局的视图,每个视图具有两个或三个水平TextView
。
我遇到的问题发生在第二个/第三个TextView
元素上。当文本太长时,它会“转到”新行,而不是从新行的左侧开始,而是从该元素开始的底部开始
可以在下图中轻松查看问题:
我尝试了RelativeLayout
和LinearLayout
,修改了TextView
填充属性,但没有成功
我的实际布局代码是:
<?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="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="16dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_beneficioDesc"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/beneficio_desc"
android:textIsSelectable="false"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_nombre"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_kmsDistanciaDesc"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/distancia_desc"
android:textIsSelectable="false"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_kmsDistancia"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_kmsDistanciaUnidad"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/distancia_unidad"
android:textIsSelectable="true"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_tarjetasDesc"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tarjetas_desc"
android:textIsSelectable="false"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_tarjetas"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_detallesDesc"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/detalles_desc"
android:textIsSelectable="false"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/promocion_detalles"
style="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
tools:context="ar.com.rouler.supromo.PromocionDetailFragment" />
</LinearLayout>
使用线性布局是否正确?这个问题有可能解决吗?2x1 en Galletitas Oreo是promotion\u nombre
中的文本,它不会去你想要的地方吗?我认为任何布局或TextView的任何属性都不可能。对于此类功能,我建议您只使用一个“文本视图”,而不是两个或三个文本视图。只需使用一个文本视图,并以实用的方式连接所有三个字符串。我不完全理解您希望它做什么。您是说水平线性布局中的第二个图元应该一直环绕到第一个图元的最左侧吗?LinearLayout不会像这样为您流动文本。您可能希望将文本连接起来,并将其全部放在一个文本视图中,如果这样做符合您的目的的话。@g20是的promocion_nombre
是该元素的ID。@FedeLerner这将是最简单的方法,因为您对所有文本视图都使用相同的样式,所以它也不会妨碍您。