以下代码,请帮我将Textview修改为一个imageview 。谢谢 。<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:didi="http://schemas.android.com/apk/res-auto" > <com.blog.demo10.NestedViewGroup android:id="@+id/dd_view_group" android:layout_width="match_parent" android:layout_height="match_parent" didi:header_id="@+id/view_bg" didi:target_id="@+id/target_layout" didi:inn_id="@+id/inner_rv" didi:header_init_top="0" didi:target_init_bottom="250"> <TextView android:id="@+id/view_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:textColor="#f00" android:textSize="25sp" android:textAllCaps="false" android:text="@string/txt_nested_scroll_bg" /> <LinearLayout android:id="@+id/target_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#fff"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/inner_rv" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </com.blog.demo10.NestedViewGroup> <androidx.appcompat.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" didi:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </RelativeLayout>
时间: 2024-04-27 14:20:58 浏览: 167
android TextView显示图片
5星 · 资源好评率100%
将TextView修改为ImageView后的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:didi="http://schemas.android.com/apk/res-auto"
>
<com.blog.demo10.NestedViewGroup
android:id="@+id/dd_view_group"
android:layout_width="match_parent"
android:layout_height="match_parent"
didi:header_id="@+id/view_bg"
didi:target_id="@+id/target_layout"
didi:inn_id="@+id/inner_rv"
didi:header_init_top="0"
didi:target_init_bottom="250">
<ImageView
android:id="@+id/view_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/your_image"
android:scaleType="centerCrop"
/>
<LinearLayout
android:id="@+id/target_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#fff">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/inner_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</com.blog.demo10.NestedViewGroup>
<androidx.appcompat.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
didi:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</RelativeLayout>
请将your_image替换成你想要的图片资源。
阅读全文