layout_marginLeft,layout_marginRight设置不可以吗?
解决方案 »
- 关于Android自定义的状态栏,跪求大神指点
- 如何实现对有规律ID的ImageButton监听,并响应
- 【问】手机如何和zigbee设备通讯?
- 自定义相机,定点对焦
- 在service中取得的music,怎么放到activity中的ListView中?
- 安卓的app图标的位置可以代码移动吗?
- 在android应用层执行linux指令
- sqlite的问题。小白求救。。
- 为什么在eclipse上无法运行,也不要报错?
- Android 性能优化,关于Skipped 31 frames! The application may be doing too much,GC频繁
- 写一个从网上下载歌词并保存到sd卡的程序的问题,急。。
- android 仿微信聊天遮罩
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_weight="1.0"
android:background="@null"
android:layout_width="0dp"
android:layout_height="1dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="Left Button"
/>
<View
android:layout_weight="1.0"
android:background="@null"
android:layout_width="0dp"
android:layout_height="1dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="Right Button"
/>
<View
android:layout_weight="1.0"
android:background="@null"
android:layout_width="0dp"
android:layout_height="1dp"/>
</LinearLayout>
s的right和c的left设置margin m/2
请问bdmh: 这个m 怎么确定是多少呢? 也就是 多少 dp呢比如说 设置的<dimen name="btn_width">30mm</dimen> 也就是 设置的 button的宽是 30mm,那么就应该 假设 屏幕的总宽为 L, 那么 m= ( L - 2*30 )/3但是 关键是 L 怎么知道是多少呢?
-----------------------------------------------
另外 我在 res/layout/test_dimen.xml 里边:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<Button
android:text="@string/test_scan"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="@string/test_control"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>然后 在 在启动的 activity 文件里边:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_dimen);但是 运行的效果 并不是想要的结果。 能说下 问题出在哪里吗? 具体怎么写呢?
请问bdmh: 这个m 怎么确定是多少呢? 也就是 多少 dp呢比如说 设置的<dimen name="btn_width">30mm</dimen> 也就是 设置的 button的宽是 30mm,那么就应该 假设 屏幕的总宽为 L, 那么 m= ( L - 2*30 )/3但是 关键是 L 怎么知道是多少呢?
-----------------------------------------------
另外 我在 res/layout/test_dimen.xml 里边:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<Button
android:text="@string/test_scan"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<Button
android:text="@string/test_control"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>然后 在 在启动的 activity 文件里边:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_dimen);但是 运行的效果 并不是想要的结果。 能说下 问题出在哪里吗? 具体怎么写呢?
如果你的BUTTON宽度固定的话完全可以看看2L的方法,如果不需要的话,像上面的代码,Button的Width设为0dip,增加Weigth=1属性自适应宽度。