【问题标题】:show an image into fragment: doesn't work将图像显示为片段:不起作用
【发布时间】:2014-01-07 16:06:44
【问题描述】:

我想将图像显示为片段,所以在我编写的 xml 中

但它不显示。为什么?问题出在哪里?

用更多代码更新我的问题。

【问题讨论】:

  • 请发布更多相关代码。
  • 你能把所有的xml内容贴出来吗?
  • 发布您的片段代码。
  • 我已经更新了我的问题
  • 你想要你的图像在哪里?您需要了解您使用的是 RelativeLayout,您需要为您的 imageview 设置一个位置

标签: java android xml


【解决方案1】:

试试这个:

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
<ImageView
    android:id="@+id/myImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/ic_home" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/button1"
    android:layout_centerHorizontal="true" />

</RelativeLayout>

我不喜欢那样给出解决方案,但是在这里,先尝试了解您的布局,为什么在这种情况下使用RelativeLayout?以及 RelativeLayout 的工作原理

【讨论】:

    猜你喜欢
    • 2022-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    相关资源
    最近更新 更多