我有一个EditText ,三个按钮,要横向布局,三个按钮在右边,edittext在左边,要占慢整行,且要适宜各种分辨率怎么写代码
解决方案 »
- 相机预览的问题
- 求助:listView中怎么添加不同的元素
- AndEngine有开发文档么,到底?我的游戏是竖屏应该如何写?
- 自定义适配器加载布局文件时显示没有这个文件,很费解,大家来看一下吧
- sqlite查一个表的列数?
- 十万加急,微信开发
- MyEclipse安装ADT
- eclipse中如何修改项目名称 具体操作
- 小白求助,Android Stdio报了一个错误无法解决
- Caused by: java.io.IOException: CreateProcess error=2, 系统找不到指定的文件
- 请问有谁做过拍照上传功能吗,就是象微博那样,可以从sd卡得到照片或拍新照片
- 模拟器和手机上运行结果竟然不一样!
<?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="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight = "1"
></EditText>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation = "vertical"
android:layout_weight = "2"
android:clickable="true"
android:gravity="center"
>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "Button1"
android:clickable="true"
android:gravity="center"
></TextView>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "Button1"
android:clickable="true"
android:gravity="center"
></TextView>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "Button1"
android:clickable="true"
android:gravity="center"
></TextView>
</LinearLayout>
</LinearLayout>
谢谢你的回答,可我要用按钮,按钮式横排的,在EditText后面
button.setLayoutParams(layoutParams); ORbutton.setHeight(pixels)
button.setWidth(pixels)
不晓得是你想要的不
button.setHeight(pixels)
button.setWidth(pixels)
我是现在XML文件中定义,然后再代码中就没这两个方法
这个呢
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight = "1"
></EditText>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation = "horizontal"
android:layout_weight = "1"
android:gravity="center"
android:layout_margin="3px"
>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "B1"
android:clickable="true"
android:gravity="center"
android:layout_margin="3px"
android:layout_weight = "1"
></Button>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "B2"
android:clickable="true"
android:gravity="center"
android:layout_margin="3px"
android:layout_weight = "1"
></Button>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "B3"
android:clickable="true"
android:gravity="center"
android:layout_margin="3px"
android:layout_weight = "1"
></Button>
</LinearLayout>
</LinearLayout>在这之中,Button内文字与边框间的空白太大,显得不大好看