android填充布局
⑴ android 代码布局简单的例子
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
ImageButton news = new ImageButton(context);
news.setId(85);
news.setOnClickListener(this);
news.setBackgroundResource(R.drawable.news);
news.setLayoutParams(new LayoutParams(33, 33));
linearLayout.addView(news);
这段代码就动态把一个ImageButton添加到一个LinearLayout中去了~
同时设定了VIEW的长宽背景布局方式等~
同理,删除掉使用的方法例如:
XXX.removeViewAt(index)
index就是这个子view在父view中是第(index+1)个添加进去的(index从0开始算的)
先尝试去修改下,再有不懂的请留言~
帮你网络的 大致就这样 下面有参考资料http://..com/question/255392766.html
⑵ android 如何多层嵌套布局
先 <include layout="@layout/another_layout" /> 这个布局 然后在 another_layout这个布局里面写上这个布局的id 并且设置可见属性为 GONE ,然后比如你是通过按钮来显示的话,你就在按钮点击的时候,把another_layout 的可见属性设置为VISSABLE
当然还有其他的实现方式,这种是比较简单的
⑶ android布局如何实现显示填满整个手机屏幕,EditText如何设置能使其样式不随输入内容太多而发生变化。
填满整个手机屏幕:
在布局文件layout中屏幕父元素内定义如下:
android:layout_width="match_parent"
android:layout_height="match_parent"
EditText设置样式使之不随内容多少而发生变化:
在EditText控件内添加如下定义:
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="8"(自定义,使之固定)
android:singleline="true"
⑷ android相对布局不能填满整个屏幕,怎么办如图!另有布局代码如下,默认的整个布局为相对布局。
删掉 android:paddingxxx="..."
这四行让你的内容填满屏幕
⑸ Android GridLayout 怎么让4个TextView均匀填充布局界面
android中,可以设置GridLayout 的排列方式,以下为设置代码:
1.layout 布局文件中设置固定的高度
android:layout_height = "20dp"
2.继承GridView,重写onMeasure方法
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
⑹ android UI实现 PopupWindow填充布局时间轴是如何实现布局的
这个有点复杂,要做好不容易,你可以用eclipse自带的
来分析,只要手机停在此界面,再点这个按钮就好了。
⑺ android tablelayout布局填不满屏幕怎么办
方案只有一种:
设置layout_height属性以及layout_weight属性,起到调整高度和均分高度的作用。
步骤:
1、设置tablelayout的高度为android:layout_height="match_parent"
2、设置tablerow的高度为
android:layout_height="wrap_parent"
android:layout_weight="1" 这句是关键,剩余高度所有tablerow均分。
⑻ 在android中布局怎么添加
在代码中可以直接new。如:TextView
textView
=
new
TextView(MainActivity.this);
也可以在xml中进行设置。如:
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
⑼ Android中常用的五种布局
Android
布局是应用界面开发的重要一环,在Android中,共有五种布局方式分别是:
线性布局:LinerLayout
表格布局:TableLayout
相对布局:RelativeLayout
绝对布局:AbsoluteLayout
帧布局:FrameLayout