大家好,我正在開發我已經完全完成的計算器應用程式,但我從一開始就面臨一個問題,解決方案可能真的很簡單,但我沒有抓住它。我將用我撰寫??的代碼示例來解釋我的問題。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FFA5E600"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world"
android:textSize="20sp"
android:background="#FFFFFFFF"/>
</RelativeLayout>
這是第二部分
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FF92CAFD"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world"
android:textSize="20sp"/>
</RelativeLayout>
所以在這段代碼中我有2個高度為wrap_content的相對布局,它有一個布局權重(1)的屬性,這意味著螢屏被分成兩部分。但是當我在第一個RelativeLayout中設定任何子視圖的高度時,它涵蓋了所有螢屏,所以我想用子視圖填充第一個布局而不覆寫全屏,如果可能的話,我不想在第二個布局子視圖中做任何更改。
我希望我說清楚了......對不起英語不好
我想將螢屏分成兩部分,但當第一個布局中任何子視圖的高度設定為匹配專利時,第一個布局會覆寫第二個布局
uj5u.com熱心網友回復:
所以有兩件事,
1.你在設定屬性后關閉了相對布局我的意思是, android:background="#FF92CAFD"/>這一行它應該像android:background="#FF92CAFD">沒有/在兩個相對布局中以它的順序結束擁有像 Textview 這樣的子視圖。我認為它不像你的代碼那樣改變它,如果是的話。
2.在相對布局中,將 layout_height 設定為 0dp,以便視圖位于父布局內。不打擾其他觀點。
我希望您的代碼在這些更改后能正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/452400.html
下一篇:卷曲引號是屬性值的有效xml
