Yan*_*niv 12 android android-layout
我有一个布局,我想使用layout_weight(1:2)分成2个视图.但是,我希望左视图的宽度至少为400dp.
例如,如果左视图通过使用权重获得420dp宽度,则保留它,但是如果它小于400dp,则让它为400dp并且给予另一视图所有其余视图.
这是我尝试过的布局,对我来说不起作用.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:minWidth="400dp"
android:background="@android:color/holo_blue_bright"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@android:color/holo_green_light"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
请帮忙,谢谢!
小智 -1
Try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:weightSum="3" >
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/holo_blue_bright"
android:minWidth="400dp" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@android:color/holo_green_light" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2350 次 |
最近记录: |