我正在开发一个"匹配以下"的应用程序.用于该应用程序的xml如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lytLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="30dp"
android:text="Match the following questions with their answers." />
<GridLayout
android:id="@+id/lytGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:columnWidth="300dp"
android:orientation="vertical"
android:rowCount="5"
android:stretchMode="columnWidth" >
<LinearLayout
android:id="@+id/Q1Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="0"
android:background="@drawable/shape_qn"
android:gravity="center" >
<TextView
android:id="@+id/Q1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="Question1" />
</LinearLayout>
<LinearLayout
android:id="@+id/A1Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="1"
android:layout_row="0"
android:background="@drawable/shape"
android:gravity="center"
android:text="Answer1" >
<TextView
android:id="@+id/A1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="Answer1" />
</LinearLayout>
<LinearLayout
android:id="@+id/Q2Lyt"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="1"
android:background="@drawable/shape_qn"
android:gravity="center" >
<TextView
android:id="@+id/Q2"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我使用ImageView控件如图所示:
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imgHangMan"
android:src="@drawable/hang0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
上面的代码在xml文件的Graphical Layout预览中显示图像.但在启动应用程序时,我看不到任何图像.此外,使用更改图像
imgHangMan = (ImageView)findViewById(R.id.imgHangMan);
imgHangMan.setImageResource(R.drawable.hang1);
Run Code Online (Sandbox Code Playgroud)
这段代码也不起作用.图像文件采用.gif格式,位于drawable文件夹中.
有什么指针吗?