是否可以从另一个xml更改包含的xml中的imageView src?
包含以下菜单栏的多个图像包括:
<include layout="@layout/panel_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top">
</include>
包含如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="@+id/linearLayout_icon_panel_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_relativelayout_settings_menu_bar_right"
android:orientation="vertical"
android:weightSum="5"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@+id/LinearLayout_titel_panel"
android:layout_alignBottom="@+id/RelativeLayout_Settings_CenterPanel"
android:layout_weight="0.86"
android:baselineAligned="false">
<ImageView
android:id="@+id/imageView_settings_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/settings" />
<ImageView
android:id="@+id/imageView_settings_contra_con"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/contracon" />
<ImageView
android:id="@+id/imageView_settings_error_log"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/errorlog" />
<ImageView
android:id="@+id/imageView_settings_reconnect"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/screen" />
<ImageView
android:id="@+id/imageView_settings_invis"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/autostart"
android:visibility="invisible" />
</LinearLayout>
现在我想通过顶部的xml包含更改android:src标签。怎么可能?
答案 0 :(得分:0)
在随附的布局中创建android.graphics.drawable.Drawable类型的变量。
,然后在include语句中设置drawable。