Android代码生成的布局里,既有横向的又要有纵向的怎么实现? android布局控件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是不知道应该怎么用代码生成,试过再建一个layout但是没用啊,再养把他们都放在一个layout里 并且这里面有纵向排列也有横向排列的控件呢?谢谢各位大神们了~~~ layout里面嵌套layout不就行了么,,,, 这是基础吧<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout></LinearLayout> 还有就是我上面的那个latout如果做一个循环的话 那么新的layout就会覆盖之前的布局了,怎么让它们循环并且以此向下继续生成,不覆盖原有的布局 大哥 我是想用纯代码在java类里生成~ 不带用xml的 解释一下,由于内容是从网上传递过来的json,而且格式也不固定,可能这道题里2个选项,下一个就3个了,所以准备在类里用代码纯生成布局,就不r.layout.(xml)了,现在问题是怎么让我的一个 LinearLayout里又有纵向又有横向,如果添加俩个 LinearLayout 的话,新的 LinearLayout 会覆盖原来的 LinearLayout ,所以这里就有俩个问题想向大家请教,1,如何让一个Layout 存在纵向和横向的俩种布局 2,如何在循环上面的 LinearLayout 的时候让第二个生成在第一个layout的下面。 求大神解答啊~ 额,那你就写两个layout,指定指定高、宽、权重,两个layout凑成一个屏幕,LinearLayout.LayoutParams params=new LinearLayout.LayoutParam(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,weight) 还是不行啊ScrollView svScrollView = new ScrollView(this);//////////////////////////////////////滚动条LinearLayout lLayout = new LinearLayout(this); LinearLayout lLayout2 = new LinearLayout(this);lLayout.setOrientation(LinearLayout.VERTICAL);lLayout2.setOrientation(LinearLayout.HORIZONTAL);TextView TV1 = new TextView(this); RadioGroup RDgroup = new RadioGroup(this);//实例化单选按钮组 TextView TV2 = new TextView(this); final TextView TV3 = new TextView(this);TV1.setText("第一道题"); TV2.setText("你选的是:"); TV3.setText("123");lLayout.addView(TV1); for(int i = 0 ; i < 5 ; i++){ RadioButton radio = new RadioButton(this); radio.setText("radio" + i); RDgroup.addView(radio); } lLayout.addView(RDgroup);lLayout2.addView(TV2); lLayout2.addView(TV3);svScrollView.addView(lLayout2); svScrollView.addView(lLayout); setContentView(svScrollView); 我是在上面多加了个滚动条的容器,然后里面建俩个layout都放进去运行就告诉我不能运行,但是单个的layout添加都是可以的,应该怎么放到一起啊 不行啊 设置之后每个LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);lLayout2.addView(TV3,lp);都加了高度还是不成啊 不行啊 设置之后每个LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);lLayout2.addView(TV3,lp);都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo 不行啊 设置之后每个LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);lLayout2.addView(TV3,lp);都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo哦 好谢谢哈 如何获取手机前台正在显示的程序呢? android滑动指导页求救 layout文件夹中xml的错误求解 大侠帮帮忙啊,急,如何解析umd漫画格式 jni 读sd卡内文件失败 Android 中FAILED BINDER TRANSACTION android 非法外联监控 Preference问题 请问如何获取车载USB设备信息(名称等) AndroidTV中使用RecyclerView布局长按遥控器导致网络请求问题 开发手机网站需要用什么技术? 调用百度地图报的错
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > <Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> <Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" /> </LinearLayout></LinearLayout>
ScrollView svScrollView = new ScrollView(this);//////////////////////////////////////滚动条
LinearLayout lLayout = new LinearLayout(this);
LinearLayout lLayout2 = new LinearLayout(this);
lLayout.setOrientation(LinearLayout.VERTICAL);
lLayout2.setOrientation(LinearLayout.HORIZONTAL);
TextView TV1 = new TextView(this);
RadioGroup RDgroup = new RadioGroup(this);//实例化单选按钮组
TextView TV2 = new TextView(this);
final TextView TV3 = new TextView(this);
TV1.setText("第一道题");
TV2.setText("你选的是:");
TV3.setText("123");
lLayout.addView(TV1);
for(int i = 0 ; i < 5 ; i++){
RadioButton radio = new RadioButton(this);
radio.setText("radio" + i);
RDgroup.addView(radio);
}
lLayout.addView(RDgroup);
lLayout2.addView(TV2);
lLayout2.addView(TV3);
svScrollView.addView(lLayout2);
svScrollView.addView(lLayout);
setContentView(svScrollView);
我是在上面多加了个滚动条的容器,然后里面建俩个layout都放进去运行就告诉我不能运行,但是单个的layout添加都是可以的,应该怎么放到一起啊
LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
lLayout2.addView(TV3,lp);
都加了高度还是不成啊
LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
lLayout2.addView(TV3,lp);
都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo
LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,200);
lLayout2.addView(TV3,lp);
都加了高度还是不成啊额,我下载过的demo,它就是设置了两个高度以后就可以叠加使用了,你等我找找那个demo哦 好谢谢哈