基于my imageview android的底部文本视图设置不正确
嗨,我的文本视图没有移动到下一行,即使我设置了MaxLength,maxsize也需要设置imageview基于宽度的高度,很抱歉我的英语不好 这是我的xml我试过的基于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
<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意味着它会从那里获取值;)感谢您的洞察力:)