我試圖設置android:layout_weight="1"
,但它什麼也沒做。Android layout_weight不起作用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:background="#fbd0d5"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.raza.helloworld.MainActivity"
tools:showIn="@layout/activity_main"
android:weightSum="1">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#fef65b"
android:text="Minnions"
android:textColor="#f44242"
android:textSize="60sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#fef65b"
android:text="Happy"
android:textColor="#f44242"
android:textSize="60sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#fef65b"
android:text="Birthday"
android:textColor="#f44242"
android:textSize="60sp"
android:textStyle="bold" />
</LinearLayout>
這段代碼有什麼問題?
在您的線性佈局(根視圖)代替機器人:weightSum = 「3」 –