android – 相对布局未定义下方

前端之家收集整理的这篇文章主要介绍了android – 相对布局未定义下方前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
现在这是我的布局 XML代码
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent">
  6.  
  7. <RelativeLayout
  8. android:id="@+id/RelativeLayout01"
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content">
  11. <ImageView
  12. android:layout_width="fill_parent"
  13. android:layout_height="fill_parent"
  14. android:background="@drawable/default1"
  15. android:id="@+id/default1"
  16. android:layout_gravity="center"
  17. android:scaleType="fitXY">
  18. </ImageView>
  19.  
  20. <ImageView
  21. android:layout_marginTop="19dp"
  22. android:layout_width="180dp"
  23. android:layout_height="45dp"
  24. android:src="@drawable/fc_postyour_best_score_bg"
  25. android:id="@+id/postscore"
  26. android:layout_alignParentRight="true"
  27. android:scaleType="fitXY">
  28. </ImageView>
  29.  
  30. <ImageButton
  31. android:layout_marginTop="22dp"
  32. android:layout_width="35dp"
  33. android:layout_height="35dp"
  34. android:background="@drawable/fctwitterup"
  35. android:layout_marginLeft="7dp"
  36. android:id="@+id/twitter"
  37. android:layout_alignRight="@id/postscore"
  38. android:scaleType="fitXY">
  39. </ImageButton>
  40.  
  41. <ImageButton
  42. android:layout_marginTop="22dp"
  43. android:layout_width="35dp"
  44. android:layout_height="35dp"
  45. android:background="@drawable/fcfacebookdown"
  46. android:id="@+id/fb"
  47. android:layout_toLeftOf="@id/twitter">
  48. </ImageButton>
  49.  
  50. <ImageButton
  51. android:layout_width="160dp"
  52. android:layout_height="40dp"
  53. android:background="@drawable/fsremove_ads_down"
  54. android:id="@+id/fsremove_ads_down"
  55. android:layout_below="@id/postscore"
  56. android:layout_alignParentRight="true"
  57. android:layout_marginBottom="3dp">
  58. </ImageButton>
  59.  
  60. <ToggleButton
  61. android:id="@+id/fsvibrate_on"
  62. android:layout_width="135dip"
  63. android:layout_height="35dip"
  64. android:textOff=""
  65. android:textOn=""
  66. android:layout_below="@+id/fsremove_ads_down"
  67. android:layout_alignParentRight="true"
  68. android:background="@drawable/fsvibrate_on">
  69. </ToggleButton>
  70.  
  71. <ImageButton
  72. android:layout_width="210dp"
  73. android:layout_height="60dp"
  74. android:background="@drawable/fcplaydown"
  75. android:id="@+id/fcplaydown"
  76. android:layout_centerInParent="true">
  77. </ImageButton>
  78.  
  79. <ToggleButton
  80. android:id="@+id/fcsoundondown"
  81. android:layout_width="35dp"
  82. android:layout_height="35dp"
  83. android:textOff=""
  84. android:textOn=""
  85. android:layout_below="@+id/fcplaydown"
  86. android:background="@drawable/fcsoundondown">
  87. </ToggleButton>
  88.  
  89.  
  90. </RelativeLayout>
  91.  
  92. </LinearLayout>

所以我的问题是@ id / fcsoundondown切换按钮我已经设置在@ id / fcplaydown下面,但是它不会低于指定的按钮,而是在“@ id / postscore”之后出现

解决方法

我不知道为什么会发生这种情况很好解释,但这与你将@ id / fcplaydown ImageButton设置为父级中心,而他的父级是具有wrap_content宽度和高度的RelativeLayout有关,布局只会让人感到困惑.

因此,将RelativeLayout设置更改为match_parent,它将起作用.

  1. <RelativeLayout
  2. android:id="@+id/RelativeLayout01"
  3. android:layout_height="match_parent"
  4. android:layout_width="match_parent">

猜你在找的Android相关文章