2012-06-26 65 views
0

我想添加水平LinearLayout编程的第一个孩子宽度,确保老二的LinearLayout - 使基于第二

通吃的宽度需要与第一个孩子将剩下的全部空间。

我没有要添加的代码,因为我尝试了很多选项,而且还没有任何工作。

有什么想法吗?

+0

给予第二个孩子的挥舞1给第一个孩子分配什么分量 –

+0

?以及放在LayoutParams上的内容? – piojo

回答

0

文本设置为android:layout_weight="0"第二个孩子。并为第一个子集android:layout_weight="1"

+0

以及放在LayoutParams上的内容? – piojo

+0

TextView tv = new TextView(v.getContext()); tv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,1f)); __最后一个参数是重量.__ – Waqas

-1

尝试这种变化的BUTTON3

<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:weightSum="1.0" > 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Back" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Read sad s as d" /> 

</LinearLayout> 
+0

你有没有注意到这个词**编程**? – Venky

+0

但可能在此之后,他可能需要在java代码中更改..as每按钮文本其他按钮宽度得到减少....... –

+0

我需要编程,我想确保第二个孩子是可见的而不是第一个 – piojo

相关问题