横向布局的linearLayout中,文本框和按钮并排时的对齐问题布局文件如下:XML code?xml version1.0 encod
横向布局的linearLayout中,文本框和按钮并排时的对齐问题
布局文件如下:
XML code<?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="76dip" android:background="#0000AA" android:orientation="horizontal" > <EditText android:layout_width="0dip" android:layout_height="38dip" android:layout_weight="1" android:background="#FF0000" android:hint="好好学习,天天向上" android:singleLine="false" /> <Button android:layout_width="38dip" android:layout_height="38dip" android:background="#FFFF00" android:text="无" /></LinearLayout>
发现显示效果始终如下,按钮总是靠下了一些像素,不知道是什么原因,高手们有没有解决办法呢?先谢谢了!
[解决办法]<?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="38dip"
android:background="#0000AA"
android:orientation="horizontal" >
<EditText
android:layout_width="0dip"
android:layout_height="38dip"
android:layout_weight="1"
android:background="#FF0000"
android:hint="好好学习,天天向上"
android:singleLine="false" />
<Button
android:layout_width="38dip"
android:layout_height="fill_parent"
android:background="#FFFF00"
android:text="无" />
</LinearLayout>
预览ok
[解决办法]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="76dip" //高度也改成38dip试试,
android:background="#0000AA"
android:orientation="horizontal" >
有文本的button挤出了点。
[解决办法]LinearLayout 中的高度改成38dip android:layout_height="38dip"
[解决办法][解决办法][解决办法]