布局应该在第一个布局底部对齐一半,在第二个布局顶部对齐一半,我对搜索没有任何线索。任何人都帮助我! ] 1Android如何在两个布局顶部布局布局
回答
这将在所有的决议,工作正确的 -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="3"
android:background="#000000" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="@color/colorAccent" />
</RelativeLayout>
</LinearLayout>
这将适用于所有分辨率 –
这对所有分辨率,一点寿,我编辑它删除最外面的RelativeLayout。只是等待审稿人确认.. :) –
是!工作正常。我只想要这个肖像模式。谢谢@Jyotman Singh –
所以我继续尝试了这一点,并成功地做这样的事情..
下面是一个简单的代码,以帮助您:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="3"
android:background="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:background="@color/colorAccent" />
</RelativeLayout>
有关如何使用RelativeLayout的更多信息,可以查看官方Android开发者网站 - RelativeLayout。 希望这有助于。
好的工作@ sept。 –
@Amit Vaghela谢谢! :) –
对不起@ sept,但我不知道为什么这是upvotes。这是错误的。设置marginBottom 50dp以获得布局在中心只是一种侥幸。它将出现在不同分辨率手机的不同位置。 –
- 1. 对齐布局顶部,其他布局
- 2. 布局布局,顶部布局的中心背景图片
- 3. 如何将布局添加到另一个布局的顶部?
- 4. Android布局在另外两个布局的中间放置一个布局
- 5. Android布局文件夹:布局,布局端口,布局区域
- 6. 在另一个布局的顶部添加布局
- 7. 在整个布局顶部拉伸div的流体布局
- 8. Android的布局 - 像布局
- 9. Android:相对布局布局
- 10. Android布局 - 位置布局
- 11. Android layoutdisplay,布局布局。
- 12. 布局布局
- 13. 五部分顶部布局
- 14. 在空布局jframe上布局布局
- 15. Android - 两列布局
- 16. Android两列布局
- 17. 布局不显示从顶部在Android
- 18. SeekBar在Android的布局顶部
- 19. android listview不会贴在布局顶部
- 20. 布局内部布局在R
- 21. android布局 - 顶部和底部
- 22. 如何在布局顶部绘制
- 23. Iniciolice布局顶部位置
- 24. AdMob联播:“顶部”布局
- 25. 如何在相对布局内放置两个布局
- 26. 布局,布局大,布局正常等
- 27. Android画布布局
- 28. Android布局如何?
- 29. Android。在布局
- 30. 如何布局根顶级
它很容易的兄弟......首先你尝试过什么? –
你有没有做过任何初始代码?你可以发布吗?并明确回答这个问题..只需使用*** RelativeLayout ***作为主要的父母布局。 –
Framelayout可以用来创建这个。 http://developer.android.com/reference/android/widget/FrameLayout.html – Stallion