我試圖並排放置兩個TextView,並且我想要一個觸摸屏幕右側和另一個左側。我不想用數字定義寬度,因爲不同尺寸的屏幕會有不同的表現。所以我試圖使用layout_gravity,由於某種原因,它不工作。兩個並排TextView的重力
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:layout_gravity="left"
android:text="rrr"
android:textColor="@color/secondTextColor"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textSize="16dp"
android:text="sss"
android:textColor="@color/secondTextColor" />
</LinearLayout>
有誰能告訴我爲什麼?謝謝!
是這兩個文本瀏覽應該在彼此之間觸摸?或者1只接觸左邊,另一個右邊,他們不接觸?如果他們之間有碰觸,那麼'weight'就足夠了,你不需要'weightSum' –