Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于my imageview android的底部文本视图设置不正确_Android - Fatal编程技术网

基于my imageview android的底部文本视图设置不正确

基于my imageview android的底部文本视图设置不正确,android,Android,嗨,我的文本视图没有移动到下一行,即使我设置了MaxLength,maxsize也需要设置imageview基于宽度的高度,很抱歉我的英语不好 这是我的xml我试过的 <RelativeLayout android:id="@+id/rlTopview" android:layout_width="match_parent" android:layout_height="wrap_content"> <Image

嗨,我的文本视图没有移动到下一行,即使我设置了MaxLength,maxsize也需要设置imageview基于宽度的高度,很抱歉我的英语不好

这是我的xml我试过的

<RelativeLayout
        android:id="@+id/rlTopview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/proimg"
            android:layout_width="200dp"
            android:layout_height="160dp"
            android:background="@drawable/categoriesicon"
            android:scaleType="centerCrop" />

        <TextView
            android:id="@+id/txtcom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/proimg"
            android:layout_marginLeft="5dp"
            android:maxEms="23"
            android:maxLines="2"
            android:scrollHorizontally="false"
            android:singleLine="false"
            android:text="Learn and Understanding \Node JS"
            android:textColor="@color/colorPrimaryBlack"
            android:textSize="18dp" /></RelativeLayout>

您的
标记的定义宽度为
200dp
。如果您希望每张卡的宽度正好为200dp,则需要填充卡的图像,如果卡的长度超过200dp,则需要包装卡下的文本,请进行以下更改:

  • 将您的
    RelativeLayout
    宽度从
    match\u parent
    更改为
    200dp
  • ImageView
    的宽度从
    200dp
    更改为
    match\u parent
  • TextView
    的宽度从
    wrap\u content
    更改为
    match\u parent

首先,请从
文本视图中删除
@+id
,它应该是
@id
。然后回到您的问题,您有三种方法,或者像这样将
ImageView
设置为全宽

<RelativeLayout
android:id="@+id/rlTopview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/proimg"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/categoriesicon"
android:scaleType="centerCrop" />

<TextView
android:id="@+id/txtcom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/proimg"
android:layout_marginLeft="5dp"
android:maxEms="23"
android:maxLines="2"
android:scrollHorizontally="false"
android:singleLine="false"
android:text="The Complete Banking\nCourses"
android:textColor="@color/colorPrimaryBlack"
android:textSize="18dp" />
</RelativeLayout>
<ImageView
android:id="@+id/proimg"
android:layout_width="200dp"
android:layout_height="160dp"
android:background="@drawable/categoriesicon"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/txtcom"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@id/proimg"
android:layout_marginLeft="5dp"
android:maxEms="23"
android:maxLines="2"
android:scrollHorizontally="false"
android:singleLine="false"
android:text="The Complete Banking\nCourses"
android:textColor="@color/colorPrimaryBlack"
android:textSize="18dp" />
<TextView
    android:id="@+id/txtcom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/proimg"
    android:align_right="@id/proimg"
    android:align_left="@id/proimg"
    android:scrollHorizontally="false"
    android:singleLine="false"
    android:text="The Complete Banking\nCourses"
    android:textColor="@color/colorPrimaryBlack"
    android:textSize="18dp" />
第三个是这样的

<RelativeLayout
android:id="@+id/rlTopview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/proimg"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/categoriesicon"
android:scaleType="centerCrop" />

<TextView
android:id="@+id/txtcom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/proimg"
android:layout_marginLeft="5dp"
android:maxEms="23"
android:maxLines="2"
android:scrollHorizontally="false"
android:singleLine="false"
android:text="The Complete Banking\nCourses"
android:textColor="@color/colorPrimaryBlack"
android:textSize="18dp" />
</RelativeLayout>
<ImageView
android:id="@+id/proimg"
android:layout_width="200dp"
android:layout_height="160dp"
android:background="@drawable/categoriesicon"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/txtcom"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@id/proimg"
android:layout_marginLeft="5dp"
android:maxEms="23"
android:maxLines="2"
android:scrollHorizontally="false"
android:singleLine="false"
android:text="The Complete Banking\nCourses"
android:textColor="@color/colorPrimaryBlack"
android:textSize="18dp" />
<TextView
    android:id="@+id/txtcom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/proimg"
    android:align_right="@id/proimg"
    android:align_left="@id/proimg"
    android:scrollHorizontally="false"
    android:singleLine="false"
    android:text="The Complete Banking\nCourses"
    android:textColor="@color/colorPrimaryBlack"
    android:textSize="18dp" />


我认为您需要将android:text=“Learn and Understanding\Node JS”更改为android:text=“Learn and Understanding\n Node JS”您的
@id
部分出错了它总是
@+id
查看更多信息@nope@+id意味着它会将id添加到R.id中,但@id意味着它会从那里获取值;)感谢您的洞察力:)