关于layout的问题 layout_marginLeft,layout_marginRight设置不可以吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/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的left和c的right设置margin为 ms的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属性自适应宽度。 左右button的weight=1,然后marin 为l,l/2; TelephonyManager的listen问题 在安卓模拟器上运行游戏终止 Activity中static静态变量释放的问题 谁做过使用nand的android系统的 recovery模式? 再次高分发帖,大家都来看看,给点想法也是好的 菜鸟的烦恼 菜鸟请教Android问题 Android 界面布局的问题? ActionBarActivity 和 FragmentActivity 不能同时继承 怎么办? 急!Android应用加入微信分享,调用不了微信 写一个从网上下载歌词并保存到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属性自适应宽度。