当我尝试在我的模拟器上使用ImageView显示图像时,它会显示出来.添加按钮后,图像不会显示.
我不知道这是否有帮助,但我的XML工作时:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
而不是工作:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="@+id/backbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"/>
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
实际上问题是你没有定义方向LinearLayout. 默认情况下它是水平的,你有layout_width按钮设置fill_parent,所以它填充整个区域.您应该将方向设置为垂直或设置android:layout_width="wrap_content"在按钮标记中.
| 归档时间: |
|
| 查看次数: |
4884 次 |
| 最近记录: |