旋转问题

问题描述:

我的Android应用程序有两个并排长度相同的图像按钮。他们填满了一条线。 我打开手机,但imagebuttons没有填满线。 即使手机旋转如何正确显示? 感谢旋转问题

把这两样,如果它按预期工作中的TableRow &检查按钮后旋转。

如果您使用的是水平布局,请确保将宽度设置为“fill_parent”,并且重量正确调整。

您还可以在onCreate中手动设置图像按钮的宽度。

使用线性布局的weight属性。将这两个按钮都放在内衬布局中,为这两个按钮指定layout_width = odp和weight = 1。权重元素允许您指定每个元素将采用的宽度的比率。下面是一个简单

<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content"      
    android:layout_alignParentBottom="true" android:layout_width="fill_parent"> 
    <Button android:text="Button" android:id="@+id/button1" 
    android:layout_height="wrap_content" android:layout_width="0dp" 
    android:layout_weight="1"> 
    </Button> 
    <Button android:text="Button" android:id="@+id/button2" 
    android:layout_height="wrap_content" android:layout_weight="1" 
    android:layout_width="0dp"> 
    </Button> 
</LinearLayout> 

编辑:样本是一个按钮,但你可以使用它的图像按钮太

+0

非常感谢您拉维,示例代码工作。 – realuser

+0

我并不意味着粗鲁无礼,但是当答案有用/正确时,您需要接受它并将其提升。 –