任何人都可以告诉我如何创建这样的布局吗?我有中间元素的问题。 制作android布局,宽度不对
0
A
回答
1
您是否需要中间视图或其中三个?
对于前者,只需在左侧和右侧创建一个60dp填充的视图。
对于后者,创建60dp宽度的固定边缘视图,对于中间的视图,设置以下属性:layout_width的0dp和layout_weight的1。
将所有这些视图放入LinearLayout中。
1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="60dp"
android:layout_height="fill_parent"
android:background="#333333"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#FF3333"
/>
<FrameLayout
android:layout_width="60dp"
android:layout_height="fill_parent"
android:background="#333333"
/>
</LinearLayout>
0
的线性布局与3个元素内:
左右elemend会有机器人:layout_width = “60dp”,而中央的一个将具有:
android:layout_width="0dp"
android:layout_weight="1"
在
这样它就会适应设备屏幕宽度
0
只需在任何元素中使用layout_margin
属性,例如TextVi ew:
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:background="#ff0000" />
相关问题
- 1. Boostrap.css制作布局100%宽度/高度
- 2. Android,布局屏幕宽度
- 3. Android布局边距制作宽度为0
- 4. JTable宽度布局
- 5. 布局宽度css
- 6. Android动态设置textview布局宽度
- 7. Android片段布局的宽度错误
- 8. Android的布局图像填充宽度
- 9. Android桌面布局宽度概率
- 10. Android布局等宽和高度
- 11. 的Android百分比宽度布局
- 12. 机器人:相对布局宽度WRAP_CONTENT
- 13. Android布局最大宽度或屏幕宽度?
- 14. Android按钮宽度的一半可用宽度 - 布局
- 15. Android布局:即使宽度/高度为0,重量也不起作用
- 16. 渲染android布局错误。对于宽度
- 17. 制作Android布局滚动
- 18. 相对布局宽度/高度不能以编程方式工作?
- 19. CSS - 固定宽度布局
- 20. Ext.Net 100%宽度布局
- 21. 自动布局制作相同的宽度为每个元素
- 22. 如何制作固定宽度的中心3列布局?
- 23. Android:相对布局布局
- 24. Android布局 - 文字太宽?
- 25. ViewPager中Android的不同宽度的布局
- 26. Android“最小宽度”布局不适用于平板电脑
- 27. 获取宽度和高度的布局
- 28. 布局宽度和高度被忽略
- 29. Javacameraview全宽作为边界布局的宽度
- 30. 当我使用0dp布局宽度时,layout_weight在android上不起作用
非常感谢,左侧和右侧的填充解决了我的问题:)我可以使用layout_weight =“1”或layout_width =“fill_parent”,两者都可以正常工作 – krinn 2012-07-12 20:49:03