我想在我的UI初始化中將LinearLayout
的寬度設置爲屏幕寬度的一半動態。我有LinearLayout
周圍RelativeLayout
包裹,層次結構如下:使用View
代替Layout
如何在運行時縮放Android佈局對象?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/left_linear_layout"
android:layout_alignParentLeft="true"
android:layout_height="fill_parent"
android:layout_width="155dp" <!--want to set this to 1/2 screen width-->
android:orientation="vertical">
...
</LinearLayout>
<LinearLayout
android:id="@+id/right_linear_layout"
android:layout_alignParentRight="true"
android:layout_height="fill_parent"
android:layout_width="385dp"><!--want to set this relative to screen width as well-->
....
</LinearLayout>
</RelativeLayout>
或者,可以在此問題得到解決?任何建議表示讚賞!