0
我有很多視圖,我在滾動視圖中添加(通過<include>
)。這些佈局是這樣的:Android:佈局總是2/3屏幕
<RelativeLayout
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
>
</RelativeLayout>
這是我包括那些佈局到fragment
佈局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<include layout="@layout/one"/>
<include layout="@layout/two"/>
<include layout="@layout/three"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
如何讓這3個佈局採取高度始終在屏幕的2/3。我希望它始終在每個設備的2/3屏幕上。 layout_weight
不能按預期工作。
爲什麼不以編程方式獲取設備的高度並設置爲您的願望視圖w ith 2/3的比例。 –
@AdnanMaqbool感謝您的評論,但我需要發佈另一個問題如何做到這一點,說實話。你能告訴我方式嗎? – soommy12
檢查我的更新答案。希望能幫助到你 –